What Does PHP Stand For?
PHP- Hypertext Preprocessor
Starting & Ending Tags
We start off by learning the 2 main tag's that you must never forget , that is the starting and ending tag's.
Starting
- Code: Select all
<?php
- Code: Select all
?>
Now that you know about the starting & ending tag's , let's start with a basic script.
- Code: Select all
<?php
echo "This is my first php script!";
?>
Variables
Now that you know some basic syntax let's start working on variables , variables are ton's of fun and one of the most important part's of PHP.
- Code: Select all
<?php
$myfirstscript = "This is my first php script!";
echo $myfirstscript;
?>
Comments
Comments are also another important thing not only in php but all languages , there used to disable any type of information inside them from actually executing with your script which ofcourse would likely cause error's.
- Code: Select all
//This is a comment
/*This is
a
comment block*/
Now these are fun to play with , they are used to execute certain code on a condition.
- Code: Select all
<?php
$mybrowser = "Fire Fox";
if ($mybrowser == "Fire Fox") { echo " You are using firefox!"; }
else { echo " You are not using firefox"; }
?>
Looping
Looping is used for many many thing's , there are more then just one loop statement, ill explain how to do the "While Loop".
- Code: Select all
<?php
$z = 1;
while ($z <= 5) {
echo $z;
$z++
}
- Code: Select all
while ($z <= 5)
- Code: Select all
echo $z
- Code: Select all
$z++
Forms
Now im assuming you have some basic understanding of html, although i will give an example of the html form but i will not be explaining it.
- Code: Select all
<form action="form.php" method="post">
Name: <input type="text" name="name">
<input type="submit" value="Submit">
- Code: Select all
<?php
$name = $_POST["name"];
echo "Hello ". $name;
?>
- Code: Select all
$_POST["name"]"
- Code: Select all
$_POST
Now this is the end of this small basic tutorial , you should now have the knowledge to execute simple script's on your server's.






