Php include and more

software development


k. Im using the function below to include my file:

<?php include("path or url to file"); ?>

Well than I also wanna put these codes somehow will it or include other files.

I was wanting to use this script to detect users browser:

<?php echo $_SERVER["HTTP_USER_AGENT"]; ?>

Detect users ip:

<?php echo $_SERVER["REMOTE_ADDR"]; ?>

Display Referrer:

<?php echo $_SERVER['HTTP_REFERER']; ?>

Load Time:

Page loaded in

<?php $load = microtime(); print (number_format($load,2)); ?>

I was wanting to combine those all in one somehow without interfering.



That’s easy enough to do. You cannot use a URL with the include() function on the DreamHost setup. Your best bet is to use the absolute (also called relative from root) path like this:

<?php include($_SERVER['DOCUMENT_ROOT']."/path/to/include.php");If you are going to put them all together, I recommend doing some error checking. Here’s everything together. It is all pretty self-explanatory:

<?php include($_SERVER['DOCUMENT_ROOT']."/path/to/include.php"); if($_SERVER['HTTP_USER_AGENT']) { echo "User agent: ".$_SERVER['HTTP_USER_AGENT']; } else { echo "Unable to detect user agent"; } print "<br />"; if($_SERVER['REMOTE_ADDR']) { echo "IP address: ".$_SERVER['REMOTE_ADDR']; } else { echo "Unable to detect IP address"; } print "<br />"; if($_SERVER['HTTP_REFERER']) { echo "Referring URI: ".$_SERVER['HTTP_REFERER']; } else { echo "Unable to detect referral data"; } print "<br />"; $load = microtime(); print "Page load time: ".number_format($load,2); ?>--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


Thanks! Everything seems to work great. You’ll have to check out the site that it will be posted on:

I need to sit down for at least a hour a day or something and study the whole php manual. What you think would be a good ultimate resource to learn php from top to bottom. Cause I can tell you been doing your reading.



Actually, I teach basic PHP in college. The best resource is the website itself, to be honest with you. I adapted some of the examples I teach with and put them on the DreamHost Wiki ( It’s a pretty good place to start.

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


That’s nice. I don’t think they offer here in Iowa. I would have to double check. Im more the computer guy than anything else…and videos games (sorry I still gotta be a kid once in awhile). Thanks for the help. I’ll be sure to thank you.



I didn’t realize you taught in a college. To bad they don’t use avatars here, as I can see you having an avatar with Professor Dumbledore hold a book with php on the cover. :slight_smile:

My website


Hey, I’m only thirty-five! Dumbledore was eleventy-billion years old or something. I used to teach PHP in college, until the college closed their web department recently. Not enough people are interested in web degrees, it seems. :frowning:

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


I have no clue to how old he was. It certainly wasn’t my intentions of making you sound old. After all your younger than me. Just having fun with you.
I agree about the drop in web design. I personally believe the high school student councilors are discouraging students from doing what the students invision themselves doing the rest of their lives.
Anyways, I think I am getting a little off topic, so apologies to the original poster.

My website