PHP Tutorials Part 1

PHP Basic Tutorial

This is a compilation of syntax on the basics of the PHP languange much like C

PHP stands for PHP Hypertext Preprocessor.

PHP syntax is enclosed in
<?php
Your code goes starts here
Your code goes ends here
?>

Outputting a string

$myString = “Hello World!”;
echo $myString;

String Creation Heredoc

$my_string = <<<TEST
Put Text Here
TEST;
echo $my_string;

Operators

Assignment Operators (=)
Arithmetic Operators (+,-,*,/,%)
Comparison Operators (==,!=,,=)
String Operators Concatenate (.)
echo $string1 . $string2
Combination Arithmetic & Assignment Operators(+=,-=,*=,/=,%=,.=)
Pre/Post-Increment ($x++,$x–)
Pre/Post-Decrement (++$x,–$x)

Comments

Single line (//,#)
Multiline (/* …….. */ )

Php Include and Require

include(“menu.php”);
require(“menu.php”); – much recommended

If Statement

$x = “PHP”;
if($x == “PHP”){
echo “Hello PHP”;
} elseif($x == “HTML”){
echo “Hello HTML”;
}else {
echo “Hello Other Languange”;
}

Switch Statement(default is optional)

$x = 1;
switch ($x){
case 1:
echo “1 is chosen”;
break;
case 2:
echo “2 is chosen”;
break;
default:
echo “default output”;
break;
}

there are more codes to come and the installation process.

from
Tizag Tutorials

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s