问题
Here is my string
$newPath = '/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js';
Now check this output
var_dump($newPath); // string(64) "/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js"
var_dump(realpath($newPath)); // bool(false)
Does anyone know why this would be returning false on me?
回答1:
Hey, you were the guy who provided the manual link in your last question! Don't just link it, read it. :)
realpath() returns FALSE on failure, e.g. if the file does not exist.
回答2:
You can find out by adding
print_r(error_get_last());
After your statement. The possible errors are described in the man page.
回答3:
A quick look on the php.net definition of realpath shows this note, which may be pertinent:
Note: The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.
来源:https://stackoverflow.com/questions/2338935/why-would-this-string-be-returning-false-in-php-when-realpathd