Академический Документы
Профессиональный Документы
Культура Документы
INTRODUCTION
PHP Operators
Arithmetic operators
Assignment operators
Comparison operators
Increment/Decrement operators
Logical operators
String operators
The PHP arithmetic operators are used with numeric values to perform common
arithmetical operations, such as addition, subtraction, multiplication etc.
Course Module 1
Web Development 2
PHP Programming Fundamentals
Sample
<html> <html>
<body> <body>
<?php <?php
//division //modulus
$x = 10; $x = 10;
$y = 6; $y = 6;
</body> </body>
</html> </html>
Answer: 1.6666666666667 Answer: 4
PHP Assignment Operators
Course Module 2
Web Development 3
PHP Programming Fundamentals
The PHP assignment operators are used with numeric values to write a value to a
variable.
The basic assignment operator in PHP is "=". It means that the left operand gets set
to the value of the assignment expression on the right.
Sample
Course Module 3
Web Development 4
PHP Programming Fundamentals
The PHP comparison operators are used to compare two values (number or string):
Sample
Course Module 4
Web Development 5
PHP Programming Fundamentals
var_dump($x == $y); // returns true var_dump($x === $y); // returns var_dump($x != $y); // returns false
because values are equal false because types are not equal because values are equal
?> ?> ?>
</body> </body> </body>
</html> </html> </html>
var_dump($x <> $y); // returns false var_dump($x !== $y); // returns true var_dump($x > $y); // returns true
because values are equal because types are not equal because $x is greater than $y
?> ?> ?>
</body> </body> </body>
</html> </html> </html>
var_dump($x < $y); // returns true var_dump($x >= $y); // returns true var_dump($x <= $y); // returns true
because $x is less than $y because $x is greater than or equal to because $x is less than or equal to $y
?> $y ?>
</body> ?> </body>
</html> </body> </html>
</html>
The PHP increment operators are used to increment a variable's value.The PHP
decrement operators are used to decrement a variable's value.
Course Module 5
Web Development 6
PHP Programming Fundamentals
Sample
<html> <html>
<body> <body>
<?php <?php
$x = 10; $x = 10;
echo ++$x; echo $x++;
?> ?>
</body> </body>
</html> </html>
Answer: 11 Answer: 10
<html> <html>
<body> <body>
<?php <?php
$x = 10; $x = 10;
echo --$x; echo $x--;
?> ?>
</body> </body>
</html> </html>
Answer: 9 Answer: 10
Course Module 6
Web Development 7
PHP Programming Fundamentals
Sample
Course Module 7
Web Development 8
PHP Programming Fundamentals
PHP has two operators that are specially designed for strings.
<html> <html>
<body> <body>
<?php <?php
$txt1 = "Hello"; $txt1 = "Hello";
$txt2 = " world!"; $txt2 = " world!";
echo $txt1 . $txt2; $txt1 .= $txt2;
?> echo $txt1;
?>
</body> </body>
</html> </html>
Course Module 8
Web Development 9
PHP Programming Fundamentals
String Delimiters
In this section, if in case you need to display special characters such as ( ‘ ), you
cannot just include it into a echo statement you need to use ( \ ) to display it.
Course Module 9
Web Development 10
PHP Programming Fundamentals
Filename:
18string_delimiters.html
Filename:
18string_delimiters.php
Arithmetic Operations
Course Module 10
Web Development 11
PHP Programming Fundamentals
Course Module 11
Web Development 12
PHP Programming Fundamentals
Filename:
19_simple_math.html
Filename:
19_simple_math.php
Course Module 12
Web Development 13
PHP Programming Fundamentals
The HTML tables allow web authors to arrange data like text, images, links, other tables,
etc. into rows and columns of cells. The HTML tables are created using the <table> tag in
which the <tr> tag is used to create table rows and <td> tag is used to create data cells.
Course Module 13
Web Development 14
PHP Programming Fundamentals
Filename:
20html_table.html
Filename:
20html_table.php
Course Module 14
Web Development 15
PHP Programming Fundamentals
Using If Statement
Course Module 15
Web Development 16
PHP Programming Fundamentals
Filename:
21if_statement.html
Course Module 16
Web Development 17
PHP Programming Fundamentals
Filename:
21if_statement.php
Course Module 17
Web Development 18
PHP Programming Fundamentals
Course Module 18
Web Development 19
PHP Programming Fundamentals
Filename:
22else_clause.html
Filename:
22else_clause.php
Using nested if
Course Module 19
Web Development 20
PHP Programming Fundamentals
Course Module 20
Web Development 21
PHP Programming Fundamentals
Filename:
23nested_if.html
A conditional statement is
determine with the following
consideration, if age > 50 prints
better start for retirement, if
years_sleep is greater than 15
prints you sleep to much
otherwise yes I mean it,
Filename:
23nested_if.php
Course Module 21
Web Development 22
PHP Programming Fundamentals
Course Module 22
Web Development 23
PHP Programming Fundamentals
Filename:
24code_formatting_rules.html
Course Module 23
Web Development 24
PHP Programming Fundamentals
Filename:
24code_formatting_rules.php
Comparison Operators
Course Module 24
Web Development 25
PHP Programming Fundamentals
Filename:
25comparison_operators.html
Course Module 25
Web Development 26
PHP Programming Fundamentals
Filename:
25comparison_operators.php
Course Module 26
Web Development 27
PHP Programming Fundamentals
Using AND
Course Module 27
Web Development 28
PHP Programming Fundamentals
Filename:
26using_and.html
Filename:
26using_and.html
Using OR
Course Module 28
Web Development 29
PHP Programming Fundamentals
Course Module 29
Web Development 30
PHP Programming Fundamentals
Filename:
27using_OR.html
Filename:
27using_OR.html
USING NOT
Course Module 30
Web Development 31
PHP Programming Fundamentals
Course Module 31
Web Development 32
PHP Programming Fundamentals
Filename:
28using_not.html
Filename:
28using_not.php
Field Validation
Course Module 32
Web Development 33
PHP Programming Fundamentals
Course Module 33
Web Development 34
PHP Programming Fundamentals
Filename:
29field_validations.html
Filename:
29field_validations.php
Course Module 34
Web Development 35
PHP Programming Fundamentals
Course Module 35
Web Development 36
PHP Programming Fundamentals
Using DIV’s
The <div> tag defines a division or a section in an HTML document. The <div> tag is used
to group block-elements to format them with CSS.
Course Module 36
Web Development 37
PHP Programming Fundamentals
Course Module 37
Web Development 38
PHP Programming Fundamentals
Filename:
31using_divs_and_forms.html
Course Module 38
Web Development 39
PHP Programming Fundamentals
Filename:
31fruits.php
Filename:
31_your_age.php
Course Module 39
Web Development 40
PHP Programming Fundamentals
References
Murach, J. (2014) Murach’s PHP and MYSQL (2nd Edition)
WEBSITE
http://php.net/
http://www.w3schools.com/php/
https://www.tutorialspoint.com/php/
Course Module 40