Is there any performance advantage if I use relative paths as argument in file_get_contents()?
file_get_contents("../../mypage.php");
v/s
file_get_contents("http://.../mypage.php");
How is file_get_contents() handled internally?
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.
If there is a performance advantage, it does not depend on php engine. Paths are processed by the web server you query.
But in this case there is going to be a performance advantage in the first case because you get the file from local fs, and in the second case you have to go through the whole network stack(http/tcp/ip) to get the response. Also first case will return php source and the second – a web page, processed by the php engine.
A clearer example:
and
are going to be equally fast.