Directly on the code
class FileTest extends SplFileInfo{ public function __destruct(){ var_dump($this->getRealPath()); }}$file = new FileTest('index.php'); //boolean falsenew FileTest('index.php'); //'E:\Apache24\htdocs\index.php'
As the above code shows, the same new object, assigned to the variable and not assigned to the variable result is not the same, does anyone know why?
Reply content:
Directly on the code
class FileTest extends SplFileInfo{ public function __destruct(){ var_dump($this->getRealPath()); }}$file = new FileTest('index.php'); //boolean falsenew FileTest('index.php'); //'E:\Apache24\htdocs\index.php'
As the above code shows, the same new object, assigned to the variable and not assigned to the variable result is not the same, does anyone know why?
I ran out of the PHP5.6 under the result:
D:\PHP5.6\php.exe E:\M5\carvincai\test\file.phpbool(false)bool(false)
Can you give me some more detailed information?
Update:
I modified the code:
getRealPath()); }}$file = new FileTest(__FILE__); //boolean falsenew FileTest(__FILE__); //'E:\Apache24\htdocs\index.php'
Results:
D:\PHP5.6\php.exe E:\M5\carvincai\test\file.phpstring(29) "E:\M5\carvincai\test\file.php"string(29) "E:\M5\carvincai\test\file.php"
Master, would you please check the file name in the constructor again?
PHP 5.6 Environment No problem, consistent results
First make sure that the ' index.php ' file is present
You must have executed under the same environment, using the ' index.php ' as the parameter passed in?