PHP is one of the most used, high-end web language. It's very easy to learn but you can't know it all :P. You'll fall in love with it very fast.
When you're getting the hang of it, you can begin injecting php into web sites ;)
First, to learn and test PHP on your PC you need an Apache server and maybe a MySQL database. Get All-in-one WAMP(Windows Apache MySQL PHP) here:
http://www.wampserver.com/
I'm not going to give all possible things, just the most recent, most used and easiest things.
Basics of PHP:
--------------
every line ends with a ; if not, the script will not execute.
Opening tag: <?php
You could also use <? but not all servers support that, so it's safer to use <?php
Closing tag: ?>
outputting text:
this is done by the echo command.
<?php
echo "hello HBH";
?>
When processed, this will give a page with Hello HBH on it.
Varaibles:
You can recognize variables by the $-sign in front of it.
<?php
$text="hello HBH";
echo $text;
?>
Again, this will give a page with Hello HBH on.
<?php
$text="hello";
$text2=" HBH";
echo $text.$text2;
?>
When combining variables, insert a . (dot) between them.
Again, this will give a page with Hello HBH on.
Now that you know the very basics I'll explain the if else statement. This compares to variables, if the comparision is true it will echo something, if it's false, something else.
<?php
$text="hello";
$text2="hbh";
if($text==$text2){
echo "True!";
}
else{
echo "False!";
}
?>
In this case, a page will pop up saying False! If $text2=hello then it'll echo True!
That's it for today! I'm not discouraging you but you still know jack about PHP :P but you're getting the principle I hope.
If you're really going to learn HBH I suggest a book by Wiley, PHP in a nutshell. For the more advanced coders out there I suggest Secure PHP & MySQL Web Developement, Third edition by sams.
I hope y'all enjoyed my first article and learned a tiny bit about this HUGE language.
Rate it boys 'n girls!
Official PHP site:
http://www.php.net
-Superpimp
http://www.wampserver.com/
I'm not going to give all possible things, just the most recent, most used and easiest things.
Basics of PHP:
--------------
every line ends with a ; if not, the script will not execute.
Opening tag: <?php
You could also use <? but not all servers support that, so it's safer to use <?php
Closing tag: ?>
outputting text:
this is done by the echo command.
<?php
echo "hello HBH";
?>
When processed, this will give a page with Hello HBH on it.
Varaibles:
You can recognize variables by the $-sign in front of it.
<?php
$text="hello HBH";
echo $text;
?>
Again, this will give a page with Hello HBH on.
<?php
$text="hello";
$text2=" HBH";
echo $text.$text2;
?>
When combining variables, insert a . (dot) between them.
Again, this will give a page with Hello HBH on.
Now that you know the very basics I'll explain the if else statement. This compares to variables, if the comparision is true it will echo something, if it's false, something else.
<?php
$text="hello";
$text2="hbh";
if($text==$text2){
echo "True!";
}
else{
echo "False!";
}
?>
In this case, a page will pop up saying False! If $text2=hello then it'll echo True!
That's it for today! I'm not discouraging you but you still know jack about PHP :P but you're getting the principle I hope.
If you're really going to learn HBH I suggest a book by Wiley, PHP in a nutshell. For the more advanced coders out there I suggest Secure PHP & MySQL Web Developement, Third edition by sams.
I hope y'all enjoyed my first article and learned a tiny bit about this HUGE language.
Rate it boys 'n girls!
Official PHP site:
http://www.php.net
-Superpimp

Main:
Posted by 
simple and combines all the basics, recommended for newbie php coders 

