| | #1 | |
| Warrior Member War Room Member Join Date: 2007
Posts: 82
Thanks: 21
Thanked 10 Times in 10 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.
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 |
| White Hat Marketer War Room Member Join Date: 2007 Location: Montgomeryville, PA
Posts: 1,546
Thanks: 77
Thanked 775 Times in 267 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: 2007
Posts: 82
Thanks: 21
Thanked 10 Times in 10 Posts
|
Thanks guys! I'll test it out. |
| |
| | #4 |
| <LunLun /> War Room Member Join Date: 2008 Location: ~Virtual = Valea Caselor (Romania)
Posts: 419
Thanks: 115
Thanked 42 Times in 33 Posts
Blog Entries: 15 |
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: 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 | |
| White Hat Marketer War Room Member Join Date: 2007 Location: Montgomeryville, PA
Posts: 1,546
Thanks: 77
Thanked 775 Times in 267 Posts
|
| |
| | ||
| |
| | #7 | |
| <LunLun /> War Room Member Join Date: 2008 Location: ~Virtual = Valea Caselor (Romania)
Posts: 419
Thanks: 115
Thanked 42 Times in 33 Posts
Blog Entries: 15 |
| |
| | ||
| |
| | #8 |
| Warrior Member War Room Member Join Date: 2007
Posts: 82
Thanks: 21
Thanked 10 Times in 10 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! |
| |
|
| Bookmarks |
| Tags |
| file, good, php, reading, remote |
| |