![]() |
PHP include question
How would I make a little file that I can add links to that shows up on 100's of sites.
The purpose is to just be able to update one file instead of 100's. Get it? |
include("filename.php");
|
i do this with a lot of my sites i just edit 1 link file say links.inc
<?include "http://www.domain.com/links.inc"?> on any site you want to do it, and all you have to do is update that one links.inc file |
Alright sweat. Thanks guys.
|
Yep, the above examples will work for what you need. But I advise that if you use a database in said include do NOT use .inc for the file extension, and like always keep the dbase connection info out of the domain root directory. :2 cents:
|
readfile();
|
Quote:
...if you want your sites to all load really slowly and use more system resources then they need to... Theres lots of methods, best one being @include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc. Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path. |
Quote:
|
include('/absolute/path/to/file'); is the best syntax. You can put a @ in front of the include if you want to supress warnings if the file doesn't exist or is unreadable from that location due to open_base_dir restrictions.
|
Quote:
|
I use:
<? include("$_SERVER[DOCUMENT_ROOT]/includes/include_filename.php"); ?> or in cases where it's an absolute path (as stated above) I omit the $_SERVER[DOCUMENT_ROOT]. |
Really only useful if all the sites are on the same server
|
Quote:
|
Quote:
|
yeah i believe so
|
Guys, when including static files (without php code), use readfile() instead of include(). </2 cents>
|
Quote:
|
just add this to a header file:
<?php $pathArr = pathinfo(__FILE__); ini_set('include_path', ini_get('include_path').':'.$pathArr['dirname'].'/includes'); ?> then you're all set - you can forget about worrying to add the full pathname - add any file to includes/ directory then include them simply with include('filename.php'); |
Quote:
|
readfile() is actually alot more then 15 times faster, uses far far far less ram, but like he said only works on static files with no php code in them
|
Just use an iframe.
|
Quote:
|
All times are GMT -7. The time now is 03:00 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123