curry.ateneo.net/joshua_gonzalez_php.ppt

  • 519 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
519
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
13
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Notes - php can do anything any other CGI program can do such as collect form data, generate dynamic page content, or send and receive cookies. - Perhaps the strongest and most significant feature in PHP is its support for a wide range of databases. Writing a database-enabled web page is incredibly simple -PHP also has support for talking to other services using protocols such as IMAP, SNMP, NNTP, POP3, HTTP and countless others.
  • -because Gutmans and Suraski found that the original PHP/FI 2.0 was originaly unpowered for a developing eCommerce application they were working on for a university. Rasmus cooperated with the two, and announce PHP3.0 as the successor of PHP/FI 2.0 and developments of the 2.0 was halted.
  • - PHP 3 used the concept of Execute while Parsing paradigm, while the concept of the PHP 4 was Compile first, execute later paradigm ****Zend is actually a series of components, at the heart of which is the Zend engine. This engine is incorporated into PHP 4.0. Other Zend components will be made available commercially. These could include such things as a debugger, support for an IDE (integrated development environment), and most important, an optimizing compiler.
  • -Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. -For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI processor. Databases Writing a database-enabled web page is incredibly simple There are three ways in which PHP can work with a Web Server. 1. The first method is using PHP as a CGI wrapper, and when run in this way the Web Server will have to start-up a new instance of PHP for each incoming connection. Due to the extra overhead that this method employs, it is resource hungry and not very efficient, and thus the slowest method. 2. The second method, which is by far the most popular, is to run PHP as a module in a multi-process Web Server, of which currently only includes Apache. A multiprocess Web Server typically has one parent process that handles and coordinates multiple child processes, which do the work of serving up the Web pages requested. When a request comes into the server, it is handled by one of the children that are not busy serving another client. Each of these children have there own instance of PHP and can’t communicate with the other PHP instances for the most part. 3. The final method is to use PHP as a plug-in for a multithreaded Web Server. PHP has support for ISAPI, WSAPI & NSAPI, which all allow PHP to be used as a plugin on multithreaded Web Servers like Microsoft Internet Information Server (IIS), Netscape FastTrack (NES/iPlanet) & O’Reily’s Web Site Pro etc. The behaviour of this model is effectively the same as that of the multi-process method as described above.
  • You can very rapidly develop web applications in PHP as compile and link is eliminated in PHP scripting language. PHP applications are very stable and do not depend on the browser technologies unlike Javascript applications which depend on browsers. PHP will give you the freedom to select any server platform. The browser does not know that the HTML page is generated by PHP
  • **Zend Encoder is available from Zend.com at the cost $2400 USD. Zend Accelerator (currently version 2.0.2) analyzes the generated opcodes and by using a "variety of optimizations and caching techniques" claims to dramatically improve the performance of PHP-based Web sites. *Without the Zend accelerator, every time a PHP script is accessed, the script is parsed and compiled by PHP's core engine (the Zend Engine) before it is executed. As long as the script does not change, the parsing and compiling is a redundant task and creates additional load on your server's CPU. *zend eliminates the need to parse and compile each time. Each time the script is requested, the precompiled version is taken from the in memory code cache. *During compilation, the code is also optimized, resulting in even faster execution time. Open Source - open source is one where the user is given a free license to remodel or recode PHP, according to their wish. You might wonder if you can I do these things without source code. Yes would be the answer. Source code is shipped with PHP. It is open source remember.
  • PHP error handling is primitive One of the most important is structured exception handling. Though it is possible to register an error handler to process errors, no facility for this is provided by the language itself. In the absence of "try . . . catch" error handling, many PHP developers forego error handling completely or use it to a much lesser extent. As is the case for most languages, you can code your way around PHP's inheriant disadvantages, but this does involve additional lines of script to achieve. Dynamically typed language, so it makes it extremely easy to hang yourself if you don't know what you are doing -the PHP language is not strongly typed (that is, if you compare the string "4" to the integer 4, the result is true), which causes problems when building larger applications, and makes debugging an application difficult. All data is passed into and out of functions/methods by value rather than by reference. -PHP does allow you to pass vars by reference using the & operator, however, it can be a tad confusing. (for instance, the infamous $foo =& new bar(); rather than $foo = new bar(); . *** inconsistent naming scheme For most part all new modules that supply categories of functions adhere to the naming convention of MODULE_FUNCTIONNAME However PHP has many core functions left over from the legacy of PHP2 & PHP3. This can be confusing and while some of the functions ucfirst() – Make the first character of the string uppercase. ord() – Return the ASCII value of a character. count() – Count the number of elements in an array. pos() – Get the current element of the array. stat() – Returns current information about a file. urlencode() – Returns a url encoded string. Objects are only slightly more than assoicative arrays with functions bound to them. -PHP is also object-oriented and it enables users to build classes and custom objects. However, PHP is not a true object-oriented programming environment. One of the most stunning examples of this is the scope of class member functions and properties. In PHP, all variables in a class are accessible externally for both reading and writing, making it impossible to hide a class' implementation. -They are handled in much the same way as the simple object types (such as integer and string values). When performing operations like variable assignment and passing the object as a parameter to a function, the whole object is copied. This can lead to inefficient development practices. Additionally, seemingly unpredictable runtime behavior can often result. PHP started off life as a procedural language, and essentially support for object oriented programming has been placed on top, and as such PHP could never really be a fully object oriented language. The main problem with PHP’s OO implementation is that a program written using OO in PHP will run slower than if a developer were to write the procedural equivalent, however, these are the trade offs to be made in achieving the balance between execution speed and code manageability. Plans for Php OO delelkopment in the future LACKS DATABSE ABASTARACTION: PHP totally lacks a database abstraction layer. The result of this is that each database module has a completely different API to access the database functions to the one before it, so while some functions may be available in one database module, they may not be available in another module. the MySQL module, the mysql_num_rows() function returns the number of rows found in the last executed query. Oracle module has no such function OCIRowCount() function looking like it might do the same (the OCIRowCount() in fact returns the number of rows effected by the last SQL statement. There are efforts within the PHP group to adopt a standard database abstraction layer, but this is in its early stages and is currently noted as being experimental.

Transcript

  • 1. 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
  • 2. History of PHP
  • 3. 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.
  • 4. 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.
  • 5. 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
  • 6. 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
  • 7. Features
    • You can very rapidly develop web applications in PHP
    • PHP applications are very stable and do not depend on the browser technologies
  • 8. 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.
  • 9. 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
  • 10. Sample Programs
  • 11. Example1
    • A basic PHP script:
    • <?php echo &quot;Hello World!&quot;; ?>
  • 12. Example 2
    • text.html
    • <FORM METHOD = POSTACTION=&quot;text.php&quot;> Who is your favorite author?
    • <INPUT AME=&quot;Author&quot;TYPE=&quot;TEXT&quot;>
    • <INPUT TYPE=SUBMIT>
    • </FORM>
    • text.php
    • <?php echo &quot;Your favorite author is: $Author&quot;;
    • ?>
  • 13. Example 3
    • Number.html
    • <FORM METHOD=GET ACTION =&quot;number.php&quot;>
    • I would like to know: <BR>
    • <INPUT NAME =&quot;opt1&quot; TYPE = &quot;Radio&quot; Value=&quot;fact&quot;> the factorial of <BR>
    • <INPUT NAME =&quot;opt1&quot; TYPE = &quot;Radio&quot; Value=&quot;prime&quot;> if the following number is prime <BR>
    • <INPUT NAME =&quot;opt1&quot; TYPE = &quot;Radio&quot; Value=&quot;next&quot;>the number following <BR> <INPUT NAME = &quot;Value&quot; TYPE=&quot;Text&quot;><BR>
    • <INPUT TYPE = SUBMIT> </FORM>
  • 14. Example 3 con’t
    • 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 &quot;$Value is not prime&quot;;
    • }
    • else{
    • echo &quot;$Value is prime&quot;;
    • }
    • }
    switch($opt1){ case &quot;fact&quot;: echo &quot;$Value has a factorial of&quot; . fact($Value); break; case &quot;prime&quot;: echo isPrime($Value); break; case &quot;next&quot;: echo &quot;The next number after $Value is &quot; . ($Value+1); break; } ?>
  • 15.  
  • 16. 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/