![]() | | ||||||||
| | #1 | |
| Warrior Member War Room Member Join Date: Sep 2007
Posts: 72
Thanks: 11
Thanked 5 Times in 5 Posts
|
Hi guys... I need your opinion about this topic. I want to use the code below to include a specific file (ex: terms.php) to all my web pages located on various servers. Quote:
Let say I have 3 servers, A, B and C. Then I have 3 different sites in server A, B and C. Each sites will have same navigation at the end of the page which I will create a navigation.php file and place it on server A. Then, I will use those code to get the navigation.php content from server A to appear on all of my web pages (in server A, B and C). So, what I do want to know is this method is really effective? Does this method will affect my web pages loading time? I used to use ssi method but I want to know is this method is more efective than ssi? The reason of using this method is, I want to easily change some of the content especially for the terms/navigation/offers in all my webpages. Thank you for your reply. -A.Z | |
| | |
| | #2 |
| Happily Self-Employed War Room Member Join Date: Jan 2007 Location: Philadelphia, PA
Posts: 797
Thanks: 16
Thanked 345 Times in 53 Posts
|
Nothing wrong with this, but I highly suggest building a caching mechanism so that the remote request doesn't happen on every page load. It both slows down response time and wastes your bandwidth. Easy cache system is to create a text file to store the cached document, and if it's older than X minutes, download the page again and write it back to the file. Otherwise, just read the contents of the local file, which is essentially instant. filemtime() gives you the modification time of the file. |
| | |
| | |
| | #3 |
| Warrior Member War Room Member Join Date: Sep 2007
Posts: 72
Thanks: 11
Thanked 5 Times in 5 Posts
|
Thanks guys! I'll test it out. |
| | |
| | #4 |
| <LunLun /> War Room Member Join Date: May 2008 Location: ~Virtual = Valea Caselor (Romania)
Posts: 377
Blog Entries: 15 Thanks: 109
Thanked 30 Times in 24 Posts
|
If I understand well, you want to include a remote php file. This is not possible, because you'll include the parsed file and not the original one. That is, if you try: $ content = file_get_contents('http://server.a/test.php'); you'll not include the test.php, but the parsed test.php, which is totally different. The only exception is if test.php is actually a static file, in which case you don't need the php extension. |
| | |
| | |
| | #5 |
| Graham Clarke Join Date: Oct 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
Be careful how you set the URL in your PHP code. If this is a variable, you'll need to make sure the proper precautions. Graham |
| | |
| | |
| | #6 | |
| Happily Self-Employed War Room Member Join Date: Jan 2007 Location: Philadelphia, PA
Posts: 797
Thanks: 16
Thanked 345 Times in 53 Posts
| Quote:
| |
| | ||
| | |
| | #7 | |
| <LunLun /> War Room Member Join Date: May 2008 Location: ~Virtual = Valea Caselor (Romania)
Posts: 377
Blog Entries: 15 Thanks: 109
Thanked 30 Times in 24 Posts
| Quote:
| |
| | ||
| | |
| | #8 |
| Warrior Member War Room Member Join Date: Sep 2007
Posts: 72
Thanks: 11
Thanked 5 Times in 5 Posts
|
Hi guys, Thank you for your response. I just use include method instead of file_get_contents. (I feel my pages load a bit slow using file_get_contents). Anyway, thanks again! |
| | |
![]() |
|
| Tags |
| file, good, php, reading, remote |
| Thread Tools | |
| |
![]() |