Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
223 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just do:

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

Or:

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

Notes:

  • 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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...