Search code examples
phppathdirectory-structure

Why would this string be returning false in PHP when realpath()'d?


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?


Solution

  • 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.