links for 2010-11-03

3/11/2010
  • Jeff Kopmanis

    First, you can use __DIR__ instead of dirname(__FILE__), and second, you shouldn’t mix absolute paths (__DIR__) with paths that could have symlinks in them ($_SERVER[‘SCRIPT_FILENAME’].  The following line accomplishes all of what that snippet above does, and without needing a fudge-factor ($header_to_root_distance):

    $RelPath = str_repeat(‘../’, (substr_count(dirname(realpath($_SERVER[‘SCRIPT_FILENAME’])), “/”) – substr_count(__DIR__, “/”)));