Elliott Elliott - 1 year ago 59
PHP Question

Include whole content of a file and echo it

I need to echo entire content of included file. I have tried the below:

echo "<?php include ('http://www.example.com/script.php'); ?>";

echo "include (\"http://www.example.com/script.php\");";

But neither works? Does PHP support this?

Answer Source

Just do:



echo file_get_contents("http://www.mysite.com/script.php");


  • This may slow down your page due to network latency or if the other server is slow.
  • This requires allow_url_fopen to be on for your PHP installation. Some hosts turn it off.
  • This will not give you the PHP code, it'll give you the HTML/text output.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download