1 / 17

Php5

Php5. CSE301 Harry Erwin, PhD. Topics. What is PHP5? Description Security Syntax Object-Orientation Speed Compilers Resources. Sources. Wikipedia Programming PHP by Lerdorf and Tatroe. What is PHP5?.

didina
Download Presentation

Php5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Php5 CSE301 Harry Erwin, PhD

  2. Topics • What is PHP5? • Description • Security • Syntax • Object-Orientation • Speed • Compilers • Resources

  3. Sources • Wikipedia • Programming PHP by Lerdorf and Tatroe

  4. What is PHP5? • A widely-used, general-purpose scripting language originally intended to support dynamic web page development. • Can be imbedded into HTML pages using the same approach as JSP or ASP pages. • The webserver needs to install a PHP processor module. • Also supports general purpose scripting. • Imperative, procedural, object-oriented, and reflective. • The latest version is 5.3.5 (which fixed a critical vulnerability).

  5. Usage • Primarily supports web applications and server-side web development. • Mediawiki • PHPwiki • Wordpress • PHPblog • Operates as a filter, taking input from a file or stream and outputting another stream of data. • Does support bytecode processing by the Zend engine. • Part of the LAMP framework.

  6. Security • Historically has been a problem. • Currently improving. • Mostly due to sloppy programming rather than language or library weaknesses. • Does not provide taint checking to detect lack of input validation. • Careful and constant attention is necessary.

  7. Syntax • Within HTML, XHTML, and XML, PHP code is delimited by <?php and ?>. Alternatively, <script language=“php”></script> or short delimiters. • Variables are identified by leading $. No type. • Handles are $$name. • References handled as $black =& $white • Function and class names, built-in constructs, and keywords are not case-sensitive; variable names are. • stdClass is a reserved class name.

  8. More Syntax • Variables can be imbedded into strings. • Newlines are whitespace • Statements terminated by semicolon • Blocks delimited by {}. Semicolon before } is mandatory. • Semicolon before closing tag is optional but wise. • Java-style comments • echo writes text • Keywords and syntax similar to other C-style languages

  9. Data Types • Eight types: • integers, • floating point numbers, • strings, • booleans, • arrays, leading position is 0, or by name • objects, • resource, • NULL • Integers are platform-dependent (32/64 bits) • Integers can be written as decimal, octal, or hexadecimal • Unsigned integer conversion is unusual. • Generally similar to C++

  10. Scope • Local defined within a function • Global defined outside functions • Static static $counter will persist within a function • Function (named parameters)

  11. Loopiness • foreach($person as $name) uses $name; $person is the array • Otherwise similar to C++

  12. Functions • Over the top. • See the PHP site. • Lots of naming conventions and inconsistencies. • No thread programming • Syntax simplified from C. • function myFunction() { return foo;} • In 5.3, functions are first class objects and anonymous functions are supported

  13. Including Code • require ‘filename’ • include ‘filename’ (if available) • filename can start with http:// or ftp://

  14. Object-Orientation • Major rewrite in PHP5 • Objects referenced by handle and not by value (pointer to pointer) • Now similar to Java. • $object = new Class; • Or • $class = ‘Person’; • $object = new $class; • -> syntax for method calls

  15. Speed • Source code is compiled on the fly to a bytecode format. Hence similar to Java in performance and about 10x slower than C. • Code optimizers exist. • Opcode caching to avoid reparsing and compiling.

  16. Compilers • Originally interpreted. Several compilers now exist: • phc • Roadsend • Raven • Phalanger • Caucho Resin/Quercus • HipHop (Facebook) • php-to-scala

  17. Resources • Free and open source libraries • Many modules for handling internet access, databases, etc.

More Related