160 likes | 281 Views
What is PHP. PHP (officially "PHP: Hypertext Preprocessor") is a server-side HTML-embedded scripting language means that code does not need to be compiled before it gets used it gets processed on the fly as necessary
E N D
What is PHP • PHP (officially "PHP: Hypertext Preprocessor") is a server-side HTML-embedded scripting language • means that code does not need to be compiled before it gets used it gets processed on the fly as necessary • has the capability of executing the script on the server and serving the output as a HTML File • it is responsible for manipulating the data which is filled in the entire web forms, any where in the net. • advantage of interacting with the databases and to perform all types of server manipulations directly
History of PHP • PHP/FI (Personal Home Page/Forms Interpreter) is the first release of PHP written by Rasmus Lerdorf in 1995. • It was inititally a simple set of Perl scripts for tracking accesses to his online resume. • PHP/FI evolved into PHP 1.0 and 2.0, advanced piece of software that understood complex scripts. • Php 2.0 was released in 1997 and it had around 50,000 domains in which it was installed in.
History (cont’n) • PHP 3.0 was created by Andi Gutmans and Zeev Suraski in 1997 as a complete rewrite of the original PHP/FI 2.0. • was the first version that closely resembles PHP as we know it today. • PHP 3.0 had strong extensibility features, with solid infrastruscture for lots of databases and API’s. • It attracted dozens of developers to join in and submit new existing modules. • by the end of 1998 it was installed on hundreds of thousands of websites.
History (cont) • PHP 4.0 officially released may 2000. -based on the ZEND engine, a rewrite of PHP’s core to achieve improved performance of complex applications, and improve modularity of PHP’s code base - May 2003, almost 13 million domains were using PHP according to Netcraft survey and PHP.nets figures
Features • PHP has support for most of the web servers today. • Apache, Microsoft IIS, PWS, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. • PHP has support for a wide range of databases • Adabas D, Ingres, Oracle (OCI7 and OCI8), dBase, InterBase, Ovrimos, Empress, FrontBase, FilePro (read-only), mSQL,Solid, Hyperwave, Direct MS-SQL, Sybase, IBM DB2, MySQL, Velocis, Informix, ODBC, Unix dbm
Features • You can very rapidly develop web applications in PHP • PHP applications are very stable and do not depend on the browser technologies
Features • Dynamically typed language, so it makes it extremely easy and fast to develop in. • PHP has Zend optimizer which speeds up the performance • PHP has a very large user base and developer base • Open Source - PHP is open source, you can modify the actual language to your needs.
Disadvantages • Primitive Error Handling • It is a Dynamically typed language, so it makes it extremely easy to hang yourself if you don't know what you are doing • Some of the function names do not have a consistent naming scheme. • Object orientation is really syntatic sugar. Objects are only slightly more than assoicative arrays with functions bound to them. • Lacks Database Abstraction
Example1 • A basic PHP script: <?phpecho "Hello World!";?>
Example 2 text.html <FORM METHOD = POSTACTION="text.php"> Who is your favorite author? <INPUT AME="Author"TYPE="TEXT"> <INPUT TYPE=SUBMIT> </FORM> text.php <?phpecho "Your favorite author is: $Author"; ?>
Example 3 Number.html <FORM METHOD=GET ACTION ="number.php"> I would like to know: <BR> <INPUT NAME ="opt1" TYPE = "Radio" Value="fact"> the factorial of <BR> <INPUT NAME ="opt1" TYPE = "Radio" Value="prime"> if the following number is prime <BR> <INPUT NAME ="opt1" TYPE = "Radio" Value="next">the number following <BR> <INPUT NAME = "Value" TYPE="Text"><BR> <INPUT TYPE = SUBMIT> </FORM>
Example 3 con’t switch($opt1){ case "fact": echo "$Value has a factorial of" . fact($Value); break; case "prime": echo isPrime($Value); break; case "next": echo "The next number after $Value is " . ($Value+1); break; } ?> number.php <?php function fact($Value){ if($Value<=1) return 1; else return $Value*fact($Value-1); } function isPrime($Value) { $Count = 2; do{ $Remainder = $Value%$Count; $Count++; }while ($Remainder !=0 AND $Count<$Value); if(($Count<$Value) OR ($Value == 0)){ echo "$Value is not prime"; } else{ echo "$Value is prime"; } }
Links • php manual: http://www.php.net/docs.php • compiler url http://www.php.net/downloads.php • http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/phpvsaspnet.asp (asp vs Php) • http://www.zend.com/