Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 4 PHP H ypertext P reprocessor Reference : Official Site :

Similar presentations


Presentation on theme: "Week 4 PHP H ypertext P reprocessor Reference : Official Site :"— Presentation transcript:

1 week 4 PHP H ypertext P reprocessor Reference : http://www.w3schools.com/php/php_intro.asp Official Site : http://www.php.net

2 PHP Hypertext Preprocessor What? ♦Open source  free to download from www.php.net ♦Server-side script (similar to asp) executed at the server end (unlike javascript) ♦Common uses ♦Form-handling ♦E-commerce ♦Shopping-carts  store information on the server

3 PHP Hypertext Preprocessor PHP files Have file extension.php e.g. index.php File contains text, html tags & scripts PHP codes enclosed in tags File MUST be parsed by web-server (cannot open directly in browser)

4 PHP Hypertext Preprocessor PHP syntax Simiar to C++ Statements end with semi-colon; Case-sensitive Same rules about variable names 1. No spaces 2. Must not begin with numbers Same logic & loop structure if ( ) { }

5 PHP Hypertext Preprocessor PHP Example: window.status = 'hello';

6 PHP Hypertext Preprocessor PHP Variables 1.Prefixed with ‘$’ 2.Begins with letters or underscore 3.Contains only a-z A-Z 0-9 _ 4.No need to define type Examples: $a1, $_x, $myVariable $1a, $my name, $x.y

7 PHP Hypertext Preprocessor PHP Superglobal Variables $_GET $_POST $_REQUEST $_SERVER

8 PHP Hypertext Preprocessor PHP Simple PHP commands echo print print_r array( ) count( $x)

9 PHP Hypertext Preprocessor PHP Arrays A variable that stores multiple values e.g. $scores 80909510060

10 PHP Hypertext Preprocessor PHP Arrays Two types of arrays indexed associative

11 PHP Hypertext Preprocessor PHP Arrays Normal (indexed) array - Each value is referenced by index numbers, starting from zero. 01234 80909510060 Index numbers values

12 PHP Hypertext Preprocessor PHP Arrays Associative array - Each value is referenced by text known as key. CLELHUMASC 80909510060 keys values

13 PHP Hypertext Preprocessor PHP Array defintion <?php $scores1 = array(80, 90, 95, 100, 60); $scores2 = array("CL " =>80, " EL " =>90, " HU " =>95, " MA " =>100, " SC " =>60); ?>

14 PHP Hypertext Preprocessor PHP Arrays Debugging arrays - The function “ print_r ” is used to display contents in an array.

15 PHP Hypertext Preprocessor PHP Arrays The following system variables are associative arrays: $_GET $_POST $_REQUEST $_SERVER $_SESSION

16 PHP Hypertext Preprocessor ☺ PHP


Download ppt "Week 4 PHP H ypertext P reprocessor Reference : Official Site :"

Similar presentations


Ads by Google