You do not need realpath() .
__FILE__ Documentation:
Full path and file name. If used inside include, the name of the included file will be returned. Starting with PHP 4.0.2, __FILE__ always contains an absolute path with the removal of symbolic links, whereas in older versions it contained a relative path in some circumstances.
So __FILE__ returns the absolute path => realpath() unnecessary
And if you use __DIR__ :
File directory. If used inside include, then the directory returns the returned file. This is equivalent to directory_name ( __FILE__ ) . This directory name does not have a trailing slash if it is not the root directory. (Added in PHP 5.3.0.)
__DIR__ also returns an absolute path, because dirname() does not disable the absolute part of the path __FILE__ => realpath() unnecessary
Comfreek
source share