3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php include 'Campanha.class'; function checkIfFileIsIncluded($files = null) { if (empty($files)) { return false; } // Caso $files seja uma String (ou qualquer outro valor do tipo Scalar), converta para um Array if (is_scalar($files)) { $files = array($files); } // Pega os nomes dos arquivos já incluídos com as funções "include", "include_once", "require" e "require_once" $includedFiles = get_included_files(); foreach ($files as $fileName) { if ( ! in_array($fileName, $includedFiles)) { return true; } } return false; } var_dump( checkIfFileIsIncluded('Campanha.class') );
Output for 5.1.0 - 7.1.0
Warning: include(Campanha.class): failed to open stream: No such file or directory in /in/TIJsu on line 3 Warning: include(): Failed opening 'Campanha.class' for inclusion (include_path='.:') in /in/TIJsu on line 3 bool(true)
Output for 4.3.2 - 5.0.5
Warning: main(Campanha.class): failed to open stream: No such file or directory in /in/TIJsu on line 3 Warning: main(): Failed opening 'Campanha.class' for inclusion (include_path='.:') in /in/TIJsu on line 3 bool(true)
Output for 4.3.0 - 4.3.1
Warning: main(Campanha.class) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/TIJsu on line 3 Warning: main() [http://www.php.net/function.main]: Failed opening 'Campanha.class' for inclusion (include_path='.:') in /in/TIJsu on line 3 bool(true)