|
|
|
|
![]() ![]() |
May 17 2007, 05:46 AM
Post
#1
|
|
|
$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 6,561 Joined: 21-September 04 From: 9r33|\| 399$ 4|\|D 5P4/\/\ Member No.: 1,218 ![]() |
Most of the code snippets are usually used for community driven sites but they do give some general idea on how php works. Don't forget if your starting out php for the first time that when saving php files that you need to have the .php extension on your files or they will not work.
Display Browser info This piece of code displays a user's browser info on how they are seeing the website CODE <?php echo $_SERVER["HTTP_USER_AGENT"]; ?> Actual Display- QUOTE Firefox - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 Internet Explorer - Browser Info: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; InfoPath.1; .NET CLR 2.0.50727) Opera - Opera/9.01 (Windows NT 5.1; U; en) Netscape - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20060912 Netscape/8.1.2 Display IP Address The next piece of code is easy to figure out, all it does is display the users current IP address and that is including using a fake IP number as well which is done by using another proxy or using a proxy site CODE <?php echo $_SERVER["REMOTE_ADDR"]; ?> Display Last Modify With this piece of code, if you remeber back in the javascript craze that there was a piece of code that would display the last tiem the page has been updated, well the same concept but in PHP CODE <? //where the main page you want to display for modification $last_modified = filemtime("thepageyouwant.php"); //print it all out print("Page Last Edited"); print(date("m/j/y h:i", $last_modified)); ?> Display ISP host/IP number With this piece of code it will display the ISP service you are using along with your IP number. CODE <?php $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo $hostname; ?> Actual Display- QUOTE c-75-68-74-121.hsd1.vt.comcast.net Display Load Time this piece of code shows a user how long it took a page to load, usually anything passed the decimal point is a bad thing, but usually hte coding is good enough that it get pretty low CODE <?php $load = microtime(); print (number_format($load,2)); ?> Update Copyright Date I find this a interesting php script, which saves you about 30 seconds of updating all your pages when a new year comes, so with this little script all you do is put in your domain name and or any other info within that echo statement. CODE <?php $year = date("Y"); //defines the year echo("© $year yoursite.com"); //the echoing ?> Thats a few I have come across and actually bookmark from the many sites I have come across, the best part you don't have to make a major alterations to these code in order for them to work. Of course for those who have being coding in php for awhile then you will be able to adapt these in your php scripts. |
|
|
|
May 17 2007, 12:19 PM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 492 Joined: 15-March 05 Member No.: 4,538 |
Hey man, thanky you for these snippets. It is nice to see something clean and simple, because usually these codes are long and complex so it is hard to understand anything if you are not a skilled programmer. I know the basics of php and this stuff is really helpful...
Thanks again for that mate, Bye |
|
|
|
May 18 2007, 03:04 AM
Post
#3
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 69 Joined: 6-May 07 From: Dallas, Texas Member No.: 42,678 |
thanks i can really use the display IP address one, and display last modify.
its not that hard to use either. |
|
|
|
May 18 2007, 05:19 AM
Post
#4
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 29 Joined: 7-September 06 Member No.: 29,569 |
http://sg.php.net/manual/en/language.varia...es.superglobals
http://sg.php.net/manual/en/reserved.variables.php ^ Helpful links for other preset PHP variables. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 12th October 2008 - 02:17 PM |