Quick PHP tutorial.
Learn to understand php in a few minuts.
First of all if you didn't read the Quick html tutorial please do so. If you don't have a PHP editor yet than go to the PHP/HTML editors page. Ok, if you read the html tutorials you will see i told you you also can add a PHP code within the body tags. I'm going to show you how right now, just read the code and after that i will explain what it means.
<html> <head> <title>Website title</title> </head> <body> <?php echo "Hello world"; ?> </body> </html>
<?php means we are starting our php script. Now you see echo "hello world"; This will show Hello world in the browser. Echo means that we are going to sent a text to the browser, in this case it is Hello world. We always close a PHP line with ; now we want to stop the php with a ?> Well wasn't that easy? Another thing you will see alot in a PHP script is a If - else statement. That looks like this:
If (1 > 5) { echo "1 > 5"; } Else { echo "1 is not greater than 5"; }
Ok now, this aint that hard. It is pretty simple. We are asking if 1 is greater than 5 or not. So, if 1 > 5 than it will show 1 > 5 But if it aint it will show 1 is not greater than 5. Pretty easy uh? You will see this alot in register scripts and such. So now you know what it means. Here another one:
$pass = "password"; // This is the password to acces the page $Passusertyped = "pasword"; //This is the pass the user give us If ($pass == $passusertyped) { // checks if the passwords are the same Echo "The password is right"; //if the password are the same this will show up } Else { //If the password aren't the same the script is going to say this echo "the password is wrong"; // Well this will show up if the passwords aren't the same }
The output would be: the password is wrong Now, you are probably wondering what those $ things are? Well those are variables, you can store text in it. (or numbers) you may know this from math So in this case it is our password & the password the user given us. We check or the passwords match if they don't we go to Else and tell the user the passwords doesn't match. Ohh and if you are wondering what the // are it are just comments that the PHP won't read, so you can remember what the code exactly does. Thats about it for now, keep checking if will update this. If you don't get anything, please feel free to contact me.
|