Skip to content

Instantly share code, notes, and snippets.

@artdevue
Forked from AgelxNash/include.validate.php
Created February 13, 2013 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artdevue/4943413 to your computer and use it in GitHub Desktop.
Save artdevue/4943413 to your computer and use it in GitHub Desktop.
<?php
/**
* Include once file
*
* @category validate
* @version 0.1
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
* @param string $file Файл который необходимо подключить в текущей папке
* @param boolean $ret Возвращать статус подключения файла или его ответ
* @return boolean Результат подключения файла
* @author Agel_Nash <Agel_Nash@xaker.ru>
*/
function inc_once($file,$ret=false){
$flag=false;
if(is_scalar($file) && file_exists($file) && is_readable($file)){
if(in_array((dirname(__FILE__).DIRECTORY_SEPARATOR.$file), get_included_files())){
//die('Файл уже был подключен ранее');
}else{
$tmp = include_once($file);
$flag = $ret ? $tmp : true;
unset($tmp);
}
}else{
//die('Нет файла или он не доступен для чтения');
}
return $flag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment