realpath vs pathinfo

#1
[eluser]xwero[/eluser]
In the index.php you can find
Code:
if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
{
    $system_folder = str_replace("\\", "/", realpath(dirname(__FILE__))).'/'.$system_folder;
}
why not use
Code:
$system_folder = str_replace('\', '/',pathinfo(__FILE__,PATHINFO_DIRNAME)).'/'.$system_folder;
Is the pathinfo less trustworthy than realpath?

#2
[eluser]Michael Wales[/eluser]
pathinfo() doesn't actually verify anything with the file system, it just merely analyzes the string that is passed to it.

Code:
<?php
print_r(pathinfo('/no/where/file.txt'));
?>

/*
Output:
Array
(
    [dirname] => /no/where
    [basename] => file.txt
    [extension] => txt
    [filename] => file
)
*/

#3
[eluser]xwero[/eluser]
i think i found out why realpath is used
Quote:Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances.

#4
[eluser]Chris Newton[/eluser]
From the PHP manual: Realpath expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input path . and return the canonicalized absolute pathname.

As far as I know, pathinfo does not do that.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.