This function scans the directory for the presence of a file. If the file is found, returns the path to it. The fact is that in the line:
if( is_file( $directory . '/' . $filename ) ) { echo 'fsd'; return $directory . '/' . $filename;}
when a file is in the same folder, the function returns a value. But if the file is in the folder the path is not returned, although the echo command shows fsd. And if I write this:
if( is_file( $directory . '/' . $filename ) ) { echo $directory . '/' . $filename; return $directory . '/' . $filename;}
echo will display the path and the function will not return it. Below is the code of the function itself:
public static function search( $directory , $filename = null ) { // 袩袪袨袙袝袪袣袗 小校些袝小孝袙袨袙袗袧袠携 校袣袗袟袗袧袧袨袡 袛袠袪袝袣孝袨袪袠袠... if(!is_dir($directory)) return null; // 袝小袥袠 袠小袣袨袦蝎袡 肖袗袡袥 袧袝 袨袩袪袝袛袝袥袝袧 - 袙袨袟袙袪袗些袗袝袦 // 袥袠楔鞋 小校些袝小孝袙校挟些校挟 袛袠袪袝袣孝袨袪袠挟 if(!$filename) return $directory; // 袩袨袠小袣 肖袗袡袥袗 (袙袣袥挟效袗袝孝 袙袨袟袦袨袞袧蝎袝 袩袨袛袛袝袪袠袣孝袨袪袠袠) $opendirectory = opendir( $directory ); while ( ( $file = readdir( $opendirectory ) ) !== false) { if( $file == "." || $file == ".." ) continue; // 袝小袥袠 肖袗袡袥 小 袟袗袛袗袧袧蝎袦 袠袦袝袧袝袦 小校些袝小孝袙校袝孝 - 袙袨袟袙袪袗些袗袝袦 袩校孝鞋 if( is_file( $directory . '/' . $filename ) ) { echo 'fsd'; return $directory . '/' . $filename;} // 袝小袥袠 肖袗袡袥 袧袝 袨袘袧袗袪校袞袝袧 - 校袝袥袠效袠袙袗袝袦 袚袥校袘袠袧校 袩袨袠小袣袗 if( is_dir( $directory . '/' . $file ) ) self::search( $directory . '/' . $file , $filename ); } closedir($opendirectory); }
Call the function:
echo $ filemanager-> search ('page', 'index.php');
I have been fighting for 2 hours ... show me where I am