views:

37

answers:

3

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?

+3  A: 

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.

Pekka
I swear I didn't find that!
alex
My eyes seem to read everything except what they should in the PHP docs.
alex
Happens :) but @Decipher's answer is also worth checking out.
Pekka
+2  A: 

You can find out by adding

print_r(error_get_last());

After your statement. The possible errors are described in the man page.

Otto Allmendinger
+2  A: 

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.

Decipher
Thanks, +1, good to know.
alex