![]()
PHP is a dynamic, HTML embedded scripting language that is used a lot by millions of websites around the world. To add onto that, it works swiftly with MySQL, which we’ll focus on later.
First off, we actually to know the basics, and the syntax of a PHP document. Open your favourite text editor and save this as a .php file.
<?php
?>
You always have to structure your PHP like that, otherwise the stuff won’t know what your talking about. One of the easiest things to do in PHP is write something, sending it to the web browser.
<?php
echo = "Pixel Clouds";
?>
This is using the echo function, although you could also use print for the same effect.
<?php
print = "Pixel Clouds";
?>
What if we want to add a comment to our new PHP code? Well there are several ways, you can use:
In PHP, variables can be very useful, they can be used to temporarily store data. They must always start in a dollar sign, and they may contain letters, numbers and underscores, however the first character cannot be a number.
Let’s make a simple variable containing the user’s IP address.
<?php
$userIP = $_SERVER["REMOTE_ADDR"];
?>
Now we’ve got their IP address, let’s build on it a little bit more using what we’ve just learnt.
<?php
$userIP = $_SERVER["REMOTE_ADDR"];
$message = "That's your IP, wow!";
echo "$userIP";
echo "
$message";
?>
Explained:
If you haven’t already noticed we’ve just created a very simple IP checker. With 4 lines of PHP!
Part 2 coming soon!
Thanks,
Arjun Vasudeva
http://avn8.com