11
PHP 101 - 02 LivingOnCodes

Beginning web programming with PHP [PHP 101-02]

Embed Size (px)

Citation preview

Page 1: Beginning web programming with PHP [PHP 101-02]

PHP 101 - 02LivingOnCodes

Page 2: Beginning web programming with PHP [PHP 101-02]

Let’s get to code

<?php echo "Hello world"; ?>

Page 3: Beginning web programming with PHP [PHP 101-02]

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

Page 4: Beginning web programming with PHP [PHP 101-02]

Basic SyntaxSemicolons

$x += 10;

The $ symbol <?php $mycounter = 1; $mystring = "Hello"; $myarray = array("One", "Two", "Three"); ?>

Page 5: Beginning web programming with PHP [PHP 101-02]

<?php ! $name1 = readline("Name1: "); $name2 = readline("Name2: "); ! echo $name1 . " and " . $name2 . " went up the hill.\n"; !!?>

Page 6: Beginning web programming with PHP [PHP 101-02]

VariablesString Variables !Numeric Variables !Arrays !Variable Naming Rules

Page 7: Beginning web programming with PHP [PHP 101-02]

OperatorsArithmetic Operators

!+ Addition $j+1

− Subtraction $j−6

* Multiplication $j*11

/ Division $j/4

% Modulus (division remainder) $j%9

++ Increment ++$j

−− Decrement −−$j

Page 8: Beginning web programming with PHP [PHP 101-02]

OperatorsAssignment Operators

!= $j=15

+= $j+=5

−= $j−=3

*= $j*=8

/= $j/=16

.= $j.=$k

%= $j%=4

Page 9: Beginning web programming with PHP [PHP 101-02]

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

Page 10: Beginning web programming with PHP [PHP 101-02]

Logical Operators

Page 11: Beginning web programming with PHP [PHP 101-02]

Functions

<?php function longdate($timestamp) { return date("l F jS Y", $timestamp); } ?>