Upload
mozammel-haque
View
268
Download
1
Embed Size (px)
Citation preview
PHP 101 - 02LivingOnCodes
Let’s get to code
<?php echo "Hello world"; ?>
Using Comments// This is a comment ! $x += 10; // Increment $x by 10 !<?php /* This is a section of multiline comments which will not be interpreted */ ?> !• You can’t nest comments
Basic SyntaxSemicolons
$x += 10;
The $ symbol <?php $mycounter = 1; $mystring = "Hello"; $myarray = array("One", "Two", "Three"); ?>
<?php ! $name1 = readline("Name1: "); $name2 = readline("Name2: "); ! echo $name1 . " and " . $name2 . " went up the hill.\n"; !!?>
VariablesString Variables !Numeric Variables !Arrays !Variable Naming Rules
OperatorsArithmetic Operators
!+ Addition $j+1
− Subtraction $j−6
* Multiplication $j*11
/ Division $j/4
% Modulus (division remainder) $j%9
++ Increment ++$j
−− Decrement −−$j
OperatorsAssignment Operators
!= $j=15
+= $j+=5
−= $j−=3
*= $j*=8
/= $j/=16
.= $j.=$k
%= $j%=4
Comparison Operators
== Is equal to!= Is not equal to> Is greater than< Is less than>= Is greater than or equal to
<= Is less than or equal to
Logical Operators
Functions
<?php function longdate($timestamp) { return date("l F jS Y", $timestamp); } ?>