Is it a sence to do something like
$dir = realpath(dirname(__FILE__));
// or for php 5.3+:
$dir = realpath(__DIR__)
Or magic constants like DIR and FILE always returns absolute path, so realpath is redundant?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need
realpath().The documentation of
__FILE__:So
__FILE__returns an absolute path =>realpath()unnecessaryAnd if you use
__DIR__:__DIR__also returns an absolute path becausedirname()doesn’t cut off the absolute part of the path of__FILE__=>realpath()unnecessary