PHP Programming: John Ryan B. Lorca Instructor I
PHP Programming: John Ryan B. Lorca Instructor I
PHP Programming
<?php ?>
Short syntax
or & concatenation
Comments
It is good practice to enter comments
//single-line comments are like this #or like this /* Multiple line comments*/
Variables Names
In PHP variable starts with a $ Followed by letter or underscore Can contain letters, numbers, underscores, or dashes No spaces Case-sensitive are different as it is case sensitive
Global variable global $student Superglobals Automatically available throughout all program $_GET $_POST $_Request $_COOKIES $_SESSION
Strings:
Strings concatenate:
Strings function:
10
Basic Math:
11
Float
12
Float
13
14
Constants
15
IF statement
If (expression)
Statement;
16
While Loop:
While (expression)
Statement;
17
18
Foreach Loop:
19
Continue:
20
Break:
21
EXERCISE
Declare a variable myInteger and set it to 69 Declare myFloat and set it to 12.5 Get the sum, difference, product, quotient of myInteger and myFloat; display results Declare a variable myString and assign Hello World to myString Concatenate and hello Philippines Display myStringDisplay your full name N times with numbering, where Nis your age Display all the numbers from 1 to 10
If the number is odd, display the number If the number is even, display Im happy today!
22