Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Programming with PHP (3) Superglobals, Form & File processing.

Similar presentations


Presentation on theme: "Web Programming with PHP (3) Superglobals, Form & File processing."— Presentation transcript:

1 Web Programming with PHP (3) Superglobals, Form & File processing

2 PHP Superglobals Several predefined variables in PHP are "superglobals", which means they are available in all scopes throughout a script. There is no need to do global $variable; to access them within functions or methods. By default, all of the superglobals are available but there are directives that affect this availability. For further information, refer to the documentation for variables_order.variables_order

3 PHP Superglobals (2) $GLOBALS : An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.$GLOBALSarray $_SERVER : $_SERVER is an array containing information such as headers, paths, and script locations.$_SERVER $_GET : An associative array of variables passed to the current script via the URL parameters.$_GET $_POST - An associative array of variables passed to the current script via the HTTP POST method.$_POST $_FILES - An associative array of items uploaded to the current script via the HTTP POST method.$_FILESarray $_COOKIE - An associative array of variables passed to the current script via HTTP Cookies.$_COOKIEarray $_SESSION - An associative array containing session variables available to the current script.$_SESSION $_REQUEST - An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.$_REQUESTarray $_GET$_POST$_COOKIE $_ENV - An associative array of variables passed to the current script via the environment method.$_ENVarray

4 Note that the print_r() inbuilt function is used to print out an array with all it’s value Program 1: $_GET_example.php <?php print_r($_GET); ?> Run : $_GET_example.php$_GET_example.php Output? Run with parameters : $_GET_example.php?name=prakash&subject=isd3 $_GET_example.php?name=prakash&subject=isd3 $_GET

5 $_POST test form First Name : Saved as : form_example1.htmlform_example1.html Program 2: $_POST_example.php$_POST_example.php <?php print_r($_POST); ?> $_POST

6 pull user submitted values from a form validate form input write / save it to a txt file In class example

7 PHP Resources PHP Home : www.php.netwww.php.net Learning PHP : www.w3schools.com/phpwww.w3schools.com/php PHP Extension & Application Repository (PEAR) : pear.php.netpear.php.net PHP Resource Index : php.resourceindex.comphp.resourceindex.com PHP Builder : www.phpbuilder.comwww.phpbuilder.com Installing Apache/PHP/MySQL (xampp) : www.apachefriends.org/en/xampp- windows.html www.apachefriends.org/en/xampp- windows.html


Download ppt "Web Programming with PHP (3) Superglobals, Form & File processing."

Similar presentations


Ads by Google