Why would this line return false in PHP when realpath () 'd?

Here is my line

$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 will give me a lie?

+1
source share
3 answers

Hey, you were the guy who provided the manual link in the last question ! Do not bind it, do not read. :)

realpath () returns FALSE on failure, for example. if the file does not exist.

+3
source

You can find out by adding

print_r(error_get_last());

After your application. Possible errors are described in the manual page .

+2
source

realpath php.net , :

Note. Running the script must have executable permissions for all directories in the hierarchy, otherwise realpath () will return FALSE .

+2
source

Source: https://habr.com/ru/post/1734499/


All Articles