PHP A Glimpse Into The Language
Object Oriented Programming Language (PHP 5) Supported on Windows, Linux, … http://www.php-mysql-tutorial.com/examples/php-tutorial/form.php. Execution Model …
More PDF Content
PHP PHP A glimpse into the language History Invented by Rasmus Lerdorf in 1994 Danish-Greenlandic Programmer Created in C to publish resume (now C++) Authored first t wo versions Now Managed by the Zend Group 4th Most Popular Language (Behind C, VB, & Java) History Major Revisions 1995 – 1.0 Personal Home Page Tools created 1998 – 3.0 Added Developers Re-Wrote Base 2000 – 4.0 Added Zend Engine (2 – Stage Parse/ Execute model) 2004 – 5.0 Zend Engine II (new object model OOP) 2008 – 6.0 Application Caching / Removed Features Overview Object Oriented Programming Language (PHP 5) Supported on Windows, Linux, Mac, & Unix The ‘P’ in L.A.M.P. Open Source under Open Source Initiative (OSI) Overview Strengths High Performance Database Support Ease of Use / Support Portability Popular Uses Product Vendors: http://www.toyboxesetc.com/ Library catalogs: http://www.childrenslibrary.org/search/search.php Webcomics: http://www.arustylife.com/ Bulletin Board: http://www.talkaboutcomics.com/phpBB2/viewforum.php?f=407 March madness brackets: [link no longer available] Demo’s IP and Browser Identification: http://www.arthurkingoftimeandspace.com/cgi-bin/ip.php Password: http://www.php-mysql-tutorial.com/examples/php-tutorial/form.php Execution Model Two-Stage Model Parse Execute Server Side Execution PHP File Parse HTML File Execute PHP Web Server Execution Model PHP Source Browser Output HTML Source if ( isset ( $_POST [ 'send' ])) { echo “Accessing username using POST : ” . $_POST [ 'username' ] . “
” ; echo “Accessing username using REQUEST : ” . $_REQUEST [ 'username' ] . “
” ; $password = $_POST [ 'password' ]; echo “Password is $password ” ; } ?> Execution Model PHP Source $ip = $_SERVER [ 'REMOTE_ADDR' ]; $agent = $_SERVER [ 'HTTP_USER_AGENT' ]; if (strpos( $agent , ‘Opera’ ) !== false ) $agent = ‘Opera’ ; else if (strpos( $agent , “MSIE” ) !== false ) $agent = ‘Internet Explorer’ ; else $agent = ‘another browser than Opera or Internet Explorer’ ; echo “Your computer IP is $ip and you are using $agent ” ; ?> Browser Output HTML Source Object Oriented Features Classes Constructors & Destructors Scope Resolution Operator :: Methods Fields Static methods public, private, protected Object Oriented Features Abstract Classes Inheritance Polymorphism Object Oriented Features Class Code Example class Car { //Member Variables private $year ; private $make ; private $color ; private $doors ; //MySQL Variables private $cid ; //MySQL Connection ID private $dbid ; //MySQL Database ID function __construct( $newYear , $newMake , $newColor , $newDoors ) { $this ->year = $newYear ; $this ->make = $newMake ; $this ->color = $newColor ; $this ->doors = $newDoors ; try { //Connect to MySQL database and return a resource id $this ->cid = mysql_connect(DB_SERVER, DB_USER_NAME, DB_USER_PWD); if (! $this ->cid) { die ( “Could not connect to MySQL database: ” . mysql_error()); } $this ->dbid = mysql_select_db(DB_NAME, $this ->cid); if (! $this ->dbid) { die ( “Could not connect to database ” . DB_NAME . “: ” . mysql_error()); } echo “New Car Object Created
” ; } catch (Exception $e ) { echo $e ->getMessage(); } } Object Oriented Features Class Code Example class Car { //Member Variables private $year ; private $make ; private $color ; private $doors ; //MySQL Variables private $cid ; //MySQL Connection ID private $dbid ; //MySQL Database ID function __construct( $newYear , $newMake , $newColor , $newDoors ) { $this ->year = $newYear ; $this ->make = $newMake ; $this ->color = $newColor ; $this ->doors = $newDoors ; try { //Connect to MySQL database and return a resource id $this ->cid = mysql_connect(DB_SERVER, DB_USER_NAME, DB_USER_PWD); if (! $this ->cid) { die ( “Could not connect to MySQL database: ” . mysql_error()); } $this ->dbid = mysql_select_db(DB_NAME, $this ->cid); if (! $this ->dbid) { die ( “Could not connect to database ” . DB_NAME . “: ” . mysql_error()); } echo “New Car Object Created
” ; } catch (Exception $e ) { echo $e ->getMessage(); } } Member Variables Object Oriented Features Class Code Example class Car { //Member Variables private $year ; private $make ; private $color ; private $doors ; //MySQL Variables private $cid ; //MySQL Connection ID private $dbid ; //MySQL Database ID function __construct( $newYear , $newMake , $newColor , $newDoors ) { $this ->year = $newYear ; $this ->make = $newMake ; $this ->color = $newColor ; $this ->doors = $newDoors ; try { //Connect to MySQL database and return a resource id $this ->cid = mysql_connect(DB_SERVER, DB_USER_NAME, DB_USER_PWD); if (! $this ->cid) { die ( “Could not connect to MySQL database: ” . mysql_error()); } $this ->dbid = mysql_select_db(DB_NAME, $this ->cid); if (! $this ->dbid) { die ( “Could not connect to database ” . DB_NAME . “: ” . mysql_error()); } echo “New Car Object Created
” ; } catch (Exception $e ) { echo $e ->getMessage(); } } Member Variables Constructor Object Oriented Features Class Code Example function __destruct() { mysql_close(<
Processing your request, Please wait....