Jump to content
xisto Community
karlo

Another Simple Php Tutorial For Beginners another easy-to-apply-and-use tutorial

Recommended Posts

Another easy to use and to apply PHP tutorial.

 

<?php print $_SERVER['USER_AGENT']; ?>
Means to OUTPUT the visitor's browser.

 

<?php print $_SERVER['REMOTE_ADDR']; ?>
Means to OUTPUT the visitor's IP address.

 

<?php print $_SERVER['SERVER_NAME']; ?>
Means to OUTPUT the current server.

 

<?php print $_SERVER['DOCUMENT_ROOT']; ?>
Menas to OUTPUT the current location where the PHP script is located.

 

How to apply:

 

Create a PHP script with any file name.

 

<html><head><title>Sample PHP Script</title></head><body><div align="center" style="font-size: 11px; font-family: verdana; color: black;">Hello! Welcome to website.com!Your current browser is: <strong><?php print $_SERVER['USER_AGENT']; ?></strong><br>Your IP address is: <strong><?php print $_SERVER['REMOTE_ADDR']; ?></strong><br><br>This script is located at <strong><?php print $_SERVER['DOCUMENT_ROOT']; ?></strong> on <strong><?php print $_SERVER['SERVER_NAME']; ?></strong><br><br><strong>If you try to hack my site, I'll know who you are!</strong></div></body></html>
There. It's finish. What do you think?

Share this post


Link to post
Share on other sites

Pretty nice. Also you can simply run this code <? phpinfo(); ?> and get the output regarding the total no. of available envoirnment variables which are available for you to use. Use those values inside $_SERVER['VARIABLE-NAME-HERE'] and impress your clients ;)

Share this post


Link to post
Share on other sites

I like $_SERVER['HTTP_REFERER'] (that's not a typo--there's supposed to be only one R after the second E). Sometimes it's interesting to see, and you could also make a database of the referrers and see what site gives you the most hits.

Share this post


Link to post
Share on other sites

Dont use print, use echo. Its' faster. Only use print when you are using the "or" operator. Liek dis<?phpfopen($file, 'w+') or print('Could not open file');?>

Share this post


Link to post
Share on other sites

Thanks, I may use this for my 404 error, just customize it. :D I don't know much about php, but I can understand that little bit. lol

Share this post


Link to post
Share on other sites

Dont use print, use echo. Its' faster. Only use print when you are using the "or" operator. Liek dis

 

<?php

fopen($file, 'w+') or print('Could not open file');

?>

54970[/snapback]

i think echo and print are the same.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.