cvs: presentations / php5_intro.xml php5xml.xml /slides/php5_intro abstract.jpg autoload.jpg che.gif different.jpg dolly.jpg dom.xml dom_ex.xml
evolution.jpg evolution.xml ivorysoap.gif magician.gif obj_abstract.php obj_abstract.xml obj_autoload.php obj_autoload.xml obj_autoload2.php
obj_clone.php obj_clone.xml obj_clone2.php obj_clone2.xml obj_con.php obj_con_des.xml obj_con_des2.xml obj_con_des4.php obj_con_des5.php obj_const.php
obj_const.xml obj_dom.php obj_exception.php obj_exceptions.xml obj_final.php obj_final.xml obj_get_set.php obj_get_set.xml obj_indirect.php
obj_indirect.xml obj_interface.php obj_interface.xml obj_method_over.php obj_method_over.xml obj_ppp.php obj_ppp.xml obj_ppp2.php obj_ppp2.xml
obj_ref.php obj_ref.xml obj_ref2.php obj_ref2.xml obj_simplexml.php obj_static.php obj_static.xml obj_tostring.php obj_tostring.xml recycle.gif
revolution.xml simplexml.xml soap.xml soap_client.php soap_ex.xml soap_server.php spl_ex1.php spl_ex1.xml spl_intro.xml sqlite.gif sqlite_ex.xml
sqlite_ex2.xml sqlite_intro.xml sqlite_oo.php sqlite_proc.php standard.xml standard2.xml static.jpg stream.jpg streams.php streams2.php
streams_ex1.xml streams_ex2.xml streams_intro.xml thankyou.xml tidy.jpg tidy.php tidy2.php tidy_ex1.xml tidy_ex2.xml tidy_intro.xml titlepage.xml
under-construction.jpg xml_intro.xml xsl.php xsl.xml xsl_ex.xml /slides/php5xml boxing.jpg buzzword.gif choices.jpg confused.gif dom.xml
dom_access.php dom_access.xml dom_access2.php dom_access2.xml dom_access3.php dom_access3.xml dom_create.php dom_create.xml dom_html.php dom_html.xml
dom_modify.php dom_modify.xml dom_validate.php dom_validate.xml dom_validate2.xml dom_xpath.php dom_xpath.xml expat.php expat_callback.inc.php
expat_struct.php extension.jpg gears.gif imperfect.jpg libs.xml parsing_xml.xml php_xml.xml php_xml2.xml reader.jpg sax.xml sax2.xml sax3.xml
simplexml.php simplexml.xml simplexml_dom.php simplexml_dom.xml simplexml_ex.xml simplexml_mod.php simplexml_mod.xml simplexml_prob.php
simplexml_problem.xml simplexml_xpath.php simplexml_xpath.xml soap.gif soap.xml soap_client.php soap_client.xml soap_cons_pros.xml soap_doc.xml
soap_doc_ex.xml soap_fault_ex.xml soap_server.php soap_server.xml soap_wdsl_client.php soap_wsdl.xml thankyou.xml thedata.php thedata.xml
titlepage.xml transformer.gif whatis.xml whyxml.xml wizardry.jpg wsdl.php xml.xml xmlread.php xmlread_valid1.php xmlreader.xml xmlreader_ex.xml
xmlreader_sum.xml xmlreader_validation.xml xmlreader_vs_sax.xml xmlrpc.jpg xmlrpc.xml xmlrpc_client.php xmlrpc_client.xml xmlrpc_cons_pros.xml
xmlrpc_request.xml xmlrpc_response.xml xmlrpc_server.php xmlrpc_server.xml xpath.jpg xpath.xml xslt.php xslt.xml xslt_ex.xml xslt_stylesheet.xml

From: Date: Wed, 13 Oct 2004 14:54:03 +0000
Subject: cvs: presentations / php5_intro.xml php5xml.xml /slides/php5_intro abstract.jpg autoload.jpg che.gif different.jpg dolly.jpg dom.xml dom_ex.xml
evolution.jpg evolution.xml ivorysoap.gif magician.gif obj_abstract.php obj_abstract.xml obj_autoload.php obj_autoload.xml obj_autoload2.php
obj_clone.php obj_clone.xml obj_clone2.php obj_clone2.xml obj_con.php obj_con_des.xml obj_con_des2.xml obj_con_des4.php obj_con_des5.php obj_const.php
obj_const.xml obj_dom.php obj_exception.php obj_exceptions.xml obj_final.php obj_final.xml obj_get_set.php obj_get_set.xml obj_indirect.php
obj_indirect.xml obj_interface.php obj_interface.xml obj_method_over.php obj_method_over.xml obj_ppp.php obj_ppp.xml obj_ppp2.php obj_ppp2.xml
obj_ref.php obj_ref.xml obj_ref2.php obj_ref2.xml obj_simplexml.php obj_static.php obj_static.xml obj_tostring.php obj_tostring.xml recycle.gif
revolution.xml simplexml.xml soap.xml soap_client.php soap_ex.xml soap_server.php spl_ex1.php spl_ex1.xml spl_intro.xml sqlite.gif sqlite_ex.xml
sqlite_ex2.xml sqlite_intro.xml sqlite_oo.php sqlite_proc.php standard.xml standard2.xml static.jpg stream.jpg streams.php streams2.php
streams_ex1.xml streams_ex2.xml streams_intro.xml thankyou.xml tidy.jpg tidy.php tidy2.php tidy_ex1.xml tidy_ex2.xml tidy_intro.xml titlepage.xml
under-construction.jpg xml_intro.xml xsl.php xsl.xml xsl_ex.xml /slides/php5xml boxing.jpg buzzword.gif choices.jpg confused.gif dom.xml
dom_access.php dom_access.xml dom_access2.php dom_access2.xml dom_access3.php dom_access3.xml dom_create.php dom_create.xml dom_html.php dom_html.xml
dom_modify.php dom_modify.xml dom_validate.php dom_validate.xml dom_validate2.xml dom_xpath.php dom_xpath.xml expat.php expat_callback.inc.php
expat_struct.php extension.jpg gears.gif imperfect.jpg libs.xml parsing_xml.xml php_xml.xml php_xml2.xml reader.jpg sax.xml sax2.xml sax3.xml
simplexml.php simplexml.xml simplexml_dom.php simplexml_dom.xml simplexml_ex.xml simplexml_mod.php simplexml_mod.xml simplexml_prob.php
simplexml_problem.xml simplexml_xpath.php simplexml_xpath.xml soap.gif soap.xml soap_client.php soap_client.xml soap_cons_pros.xml soap_doc.xml
soap_doc_ex.xml soap_fault_ex.xml soap_server.php soap_server.xml soap_wdsl_client.php soap_wsdl.xml thankyou.xml thedata.php thedata.xml
titlepage.xml transformer.gif whatis.xml whyxml.xml wizardry.jpg wsdl.php xml.xml xmlread.php xmlread_valid1.php xmlreader.xml xmlreader_ex.xml
xmlreader_sum.xml xmlreader_validation.xml xmlreader_vs_sax.xml xmlrpc.jpg xmlrpc.xml xmlrpc_client.php xmlrpc_client.xml xmlrpc_cons_pros.xml
xmlrpc_request.xml xmlrpc_response.xml xmlrpc_server.php xmlrpc_server.xml xpath.jpg xpath.xml xslt.php xslt.xml xslt_ex.xml xslt_stylesheet.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1076@lists.php.net to get a copy of this message
iliaa Wed Oct 13 10:54:03 2004 EDT Added files: /presentations php5_intro.xml php5xml.xml /presentations/slides/php5_intro abstract.jpg autoload.jpg che.gif different.jpg dolly.jpg dom.xml dom_ex.xml evolution.jpg evolution.xml ivorysoap.gif magician.gif obj_abstract.php obj_abstract.xml obj_autoload.php obj_autoload.xml obj_autoload2.php obj_clone.php obj_clone.xml obj_clone2.php obj_clone2.xml obj_con.php obj_con_des.xml obj_con_des2.xml obj_con_des4.php obj_con_des5.php obj_const.php obj_const.xml obj_dom.php obj_exception.php obj_exceptions.xml obj_final.php obj_final.xml obj_get_set.php obj_get_set.xml obj_indirect.php obj_indirect.xml obj_interface.php obj_interface.xml obj_method_over.php obj_method_over.xml obj_ppp.php obj_ppp.xml obj_ppp2.php obj_ppp2.xml obj_ref.php obj_ref.xml obj_ref2.php obj_ref2.xml obj_simplexml.php obj_static.php obj_static.xml obj_tostring.php obj_tostring.xml recycle.gif revolution.xml simplexml.xml soap.xml soap_client.php soap_ex.xml soap_server.php spl_ex1.php spl_ex1.xml spl_intro.xml sqlite.gif sqlite_ex.xml sqlite_ex2.xml sqlite_intro.xml sqlite_oo.php sqlite_proc.php standard.xml standard2.xml static.jpg stream.jpg streams.php streams2.php streams_ex1.xml streams_ex2.xml streams_intro.xml thankyou.xml tidy.jpg tidy.php tidy2.php tidy_ex1.xml tidy_ex2.xml tidy_intro.xml titlepage.xml under-construction.jpg xml_intro.xml xsl.php xsl.xml xsl_ex.xml /presentations/slides/php5xml boxing.jpg buzzword.gif choices.jpg confused.gif dom.xml dom_access.php dom_access.xml dom_access2.php dom_access2.xml dom_access3.php dom_access3.xml dom_create.php dom_create.xml dom_html.php dom_html.xml dom_modify.php dom_modify.xml dom_validate.php dom_validate.xml dom_validate2.xml dom_xpath.php dom_xpath.xml expat.php expat_callback.inc.php expat_struct.php extension.jpg gears.gif imperfect.jpg libs.xml parsing_xml.xml php_xml.xml php_xml2.xml reader.jpg sax.xml sax2.xml sax3.xml simplexml.php simplexml.xml simplexml_dom.php simplexml_dom.xml simplexml_ex.xml simplexml_mod.php simplexml_mod.xml simplexml_prob.php simplexml_problem.xml simplexml_xpath.php simplexml_xpath.xml soap.gif soap.xml soap_client.php soap_client.xml soap_cons_pros.xml soap_doc.xml soap_doc_ex.xml soap_fault_ex.xml soap_server.php soap_server.xml soap_wdsl_client.php soap_wsdl.xml thankyou.xml thedata.php thedata.xml titlepage.xml transformer.gif whatis.xml whyxml.xml wizardry.jpg wsdl.php xml.xml xmlread.php xmlread_valid1.php xmlreader.xml xmlreader_ex.xml xmlreader_sum.xml xmlreader_validation.xml xmlreader_vs_sax.xml xmlrpc.jpg xmlrpc.xml xmlrpc_client.php xmlrpc_client.xml xmlrpc_cons_pros.xml xmlrpc_request.xml xmlrpc_response.xml xmlrpc_server.php xmlrpc_server.xml xpath.jpg xpath.xml xslt.php xslt.xml xslt_ex.xml xslt_stylesheet.xml Log: PHP|Works talks.

http://cvs.php.net/co.php/presentations/php5_intro.xml?r=1.1&p=1 Index: presentations/php5_intro.xml +++ presentations/php5_intro.xml <presentation template="php2" titlecolor="#1111aa" navbarbackground="url(images/trans-ffffff.png)" logo1="images/php-med-trans-light.gif" titlesize="2em" navbarheight="4.1em"> <topic>PHP 5</topic> <title>Introduction to PHP 5</title> <copyright>(c) Copyright 2004 Ilia Alshanetsky</copyright> <event>PHP|Works</event> <location>Toronto, Canada</location> <date>September 22rd 2004</date> <speaker>Ilia Alshanetsky</speaker> <navmode>html</navmode> <url>http://talks.php.net/</url> <slide>slides/php5_intro/titlepage.xml</slide> <slide>slides/php5_intro/evolution.xml</slide> <slide>slides/php5_intro/revolution.xml</slide> <slide>slides/php5_intro/obj_ref.xml</slide> <slide>slides/php5_intro/obj_ref2.xml</slide> <slide>slides/php5_intro/obj_clone.xml</slide> <slide>slides/php5_intro/obj_clone2.xml</slide> <slide>slides/php5_intro/obj_con_des.xml</slide> <slide>slides/php5_intro/obj_con_des2.xml</slide> <slide>slides/php5_intro/obj_ppp.xml</slide> <slide>slides/php5_intro/obj_ppp2.xml</slide> <slide>slides/php5_intro/obj_static.xml</slide> <slide>slides/php5_intro/obj_final.xml</slide> <slide>slides/php5_intro/obj_const.xml</slide> <slide>slides/php5_intro/obj_indirect.xml</slide> <slide>slides/php5_intro/obj_autoload.xml</slide> <slide>slides/php5_intro/obj_get_set.xml</slide> <slide>slides/php5_intro/obj_method_over.xml</slide> <slide>slides/php5_intro/obj_abstract.xml</slide> <slide>slides/php5_intro/obj_interface.xml</slide> <slide>slides/php5_intro/obj_exceptions.xml</slide> <slide>slides/php5_intro/obj_tostring.xml</slide> <slide>slides/php5_intro/xml_intro.xml</slide> <slide>slides/php5_intro/simplexml.xml</slide> <slide>slides/php5_intro/dom.xml</slide> <slide>slides/php5_intro/dom_ex.xml</slide> <slide>slides/php5_intro/xsl.xml</slide> <slide>slides/php5_intro/xsl_ex.xml</slide> <slide>slides/php5_intro/soap.xml</slide> <slide>slides/php5_intro/soap_ex.xml</slide> <slide>slides/php5_intro/sqlite_intro.xml</slide> <slide>slides/php5_intro/sqlite_ex.xml</slide> <slide>slides/php5_intro/sqlite_ex2.xml</slide> <slide>slides/php5_intro/tidy_intro.xml</slide> <slide>slides/php5_intro/tidy_ex1.xml</slide> <slide>slides/php5_intro/tidy_ex2.xml</slide> <slide>slides/php5_intro/spl_intro.xml</slide> <slide>slides/php5_intro/spl_ex1.xml</slide> <slide>slides/php5_intro/streams_intro.xml</slide> <slide>slides/php5_intro/streams_ex1.xml</slide> <slide>slides/php5_intro/streams_ex2.xml</slide> <slide>slides/php5_intro/standard.xml</slide> <slide>slides/php5_intro/standard2.xml</slide> <slide>slides/php5_intro/thankyou.xml</slide> </presentation> http://cvs.php.net/co.php/presentations/php5xml.xml?r=1.1&p=1 Index: presentations/php5xml.xml +++ presentations/php5xml.xml <presentation template="php2" titlecolor="#1111aa" navbarbackground="url(images/trans-ffffff.png)" logo1="images/php-med-trans-light.gif" titlesize="2em" navbarheight="4.1em"> <topic>XML</topic> <title>PHP 5 and XML</title> <copyright>(c) Copyright 2004 Ilia Alshanetsky</copyright> <event>PHP|Works</event> <location>Toronto, Canada</location> <date>September 23rd 2004</date> <speaker>Ilia Alshanetsky</speaker> <navmode>html</navmode> <url>http://talks.php.net/</url> <slide>slides/php5xml/titlepage.xml</slide> <slide>slides/php5xml/whatis.xml</slide> <slide>slides/php5xml/whyxml.xml</slide> <slide>slides/php5xml/xml.xml</slide> <slide>slides/php5xml/php_xml.xml</slide> <slide>slides/php5xml/parsing_xml.xml</slide> <slide>slides/php5xml/php_xml2.xml</slide> <slide>slides/php5xml/libs.xml</slide> <slide>slides/php5xml/sax.xml</slide> <slide>slides/php5xml/sax2.xml</slide> <slide>slides/php5xml/sax3.xml</slide> <slide>slides/php5xml/xmlreader.xml</slide> <slide>slides/php5xml/xmlreader_vs_sax.xml</slide> <slide>slides/php5xml/xmlreader_ex.xml</slide> <slide>slides/php5xml/xmlreader_validation.xml</slide> <slide>slides/php5xml/xmlreader_sum.xml</slide> <slide>slides/php5xml/simplexml.xml</slide> <slide>slides/php5xml/simplexml_ex.xml</slide> <slide>slides/php5xml/xpath.xml</slide> <slide>slides/php5xml/simplexml_xpath.xml</slide> <slide>slides/php5xml/simplexml_mod.xml</slide> <slide>slides/php5xml/simplexml_dom.xml</slide> <slide>slides/php5xml/simplexml_problem.xml</slide> <slide>slides/php5xml/dom.xml</slide> <slide>slides/php5xml/dom_access.xml</slide> <slide>slides/php5xml/dom_access2.xml</slide> <slide>slides/php5xml/dom_access3.xml</slide> <slide>slides/php5xml/dom_xpath.xml</slide> <slide>slides/php5xml/dom_create.xml</slide> <slide>slides/php5xml/dom_modify.xml</slide> <slide>slides/php5xml/dom_validate.xml</slide> <slide>slides/php5xml/dom_validate2.xml</slide> <slide>slides/php5xml/dom_html.xml</slide> <slide>slides/php5xml/xmlrpc.xml</slide> <slide>slides/php5xml/xmlrpc_request.xml</slide> <slide>slides/php5xml/xmlrpc_response.xml</slide> <slide>slides/php5xml/xmlrpc_server.xml</slide> <slide>slides/php5xml/xmlrpc_client.xml</slide> <slide>slides/php5xml/xmlrpc_cons_pros.xml</slide> <slide>slides/php5xml/soap.xml</slide> <slide>slides/php5xml/soap_doc.xml</slide> <slide>slides/php5xml/soap_doc_ex.xml</slide> <slide>slides/php5xml/soap_fault_ex.xml</slide> <slide>slides/php5xml/soap_server.xml</slide> <slide>slides/php5xml/soap_wsdl.xml</slide> <slide>slides/php5xml/soap_client.xml</slide> <slide>slides/php5xml/soap_cons_pros.xml</slide> <slide>slides/php5xml/xslt.xml</slide> <slide>slides/php5xml/xslt_stylesheet.xml</slide> <slide>slides/php5xml/xslt_ex.xml</slide> <slide>slides/php5xml/thankyou.xml</slide> </presentation> http://cvs.php.net/co.php/presentations/slides/php5_intro/dom.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/dom.xml +++ presentations/slides/php5_intro/dom.xml <slide title="DOM"> <blurb> %DOM% is a complete rewrite of the %DOMXML% extension. The new extensions makes use of PHP 5's OO features to offer a robust interface. </blurb> <list title="Capabilities"> <bullet>DOM Level 3 Load and Save Support</bullet> <bullet>XPath</bullet> <bullet>Validation support</bullet> <bullet>NamedNodeMap support</bullet> <bullet>Complete Namespaces support</bullet> <bullet>Interop with SimpleXML and XSLT</bullet> <bullet>HTML Support</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/dom_ex.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/dom_ex.xml +++ presentations/slides/php5_intro/dom_ex.xml <slide title="Creating XML w/DOM"> <example filename="obj_dom.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/evolution.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/evolution.xml +++ presentations/slides/php5_intro/evolution.xml <slide title="Evolutionary Changes"> <break /> <image filename="evolution.jpg" align="right" /> <list fontsize="3em"> <bullet>Improved Performance.</bullet> <bullet>Some New Standard Functions.</bullet> <bullet>Improved Streams Support</bullet> <bullet>New &amp; Exciting Bugs ;-)</bullet> </list> <break /> <blurb fontsize="3em"> Language internals remain mostly the same. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_abstract.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_abstract.php +++ presentations/slides/php5_intro/obj_abstract.php <?php abstract class ab { abstract public function test(); } /* the implementing class must implement all methods * specified in the abstract class */ class imp_ab extends ab { public function test() { echo "implemented class was called"; } } $a = new imp_ab(); $a->test(); ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_abstract.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_abstract.xml +++ presentations/slides/php5_intro/obj_abstract.xml <slide title="Abstract Classes"> <image filename="abstract.jpg" align="right" /> <blurb> PHP 5 introduces %abstract% classes and methods. An abstract method only declares the method's signature and does not provide an implementation. A class that contains abstract methods needs to be declared abstract. </blurb> <example filename="obj_abstract.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_autoload.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_autoload.php +++ presentations/slides/php5_intro/obj_autoload.php <?php function __autoload($classname) { $classes = array('foo' => 'obj_autoload2.php'); include_once($classes[$classname]); } $a = new foo(); /* since the class foo is undeclared, PHP will execute the __autoload() * function and using the class name try to perform an operation that will * ideally result in the declaration of the class */ ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_autoload.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_autoload.xml +++ presentations/slides/php5_intro/obj_autoload.xml <slide title="Autoload"> <image filename="autoload.jpg" align="right" /> <blurb> To make the developer simpler, PHP 5 introduces a global-scope function %__autoload()% that will automatically satisfy class dependencies at run time. </blurb> <example title="Source Class" filename="obj_autoload2.php" fontsize="1.5em" /> <example title="Main Script" filename="obj_autoload.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_autoload2.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_autoload2.php +++ presentations/slides/php5_intro/obj_autoload2.php <?php class foo { public $bar; } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_clone.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_clone.php +++ presentations/slides/php5_intro/obj_clone.php <?php class foo { var $bar; function baz($val) { $this->bar = $val; } } $a = new foo(); $b = clone $a; // make $b contain a separate copy of $a $a->baz(2); var_dump($b->bar != $a->bar); // True ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_clone.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_clone.xml +++ presentations/slides/php5_intro/obj_clone.xml <slide title="Object Cloning"> <image filename="dolly.jpg" align="right" /> <blurb> To make a copy of an object ala PHP 4, a special __clone() method should be used. </blurb> <example filename="obj_clone.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_clone2.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_clone2.php +++ presentations/slides/php5_intro/obj_clone2.php <?php class foo { var $bar, $is_clone = 0; function baz($val) { $this->bar = $val; } function __clone() { $this->is_clone = 1; } } $a = new foo(); $b = clone $a; // make $b contain a separate copy of $a echo $b->is_clone; // will print 1 ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_clone2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_clone2.xml +++ presentations/slides/php5_intro/obj_clone2.xml <slide title="Object Cloning"> <image filename="dolly.jpg" align="right" /> <blurb> You can specify your own __clone() method that will be executed when an object is cloned. </blurb> <example filename="obj_clone2.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_con.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_con.php +++ presentations/slides/php5_intro/obj_con.php <?php class old { function old() { $this->val = 123; } } class newer extends old { function __construct() { /* will work despite the older class using PHP 4 style constructor */ parent::__construct(); } } $a = new newer(); echo $a->val; // 123 ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_con_des.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_con_des.xml +++ presentations/slides/php5_intro/obj_con_des.xml <slide title="Construct/Destruct"> <image filename="under-construction.jpg" align="right" /> <blurb> In PHP 4 constructors were supported by creating a function with the same name as the class. </blurb> <example filename="obj_con_des4.php" fontsize="1.5em" /> <blurb> In PHP 5, the %__construct()% method will be called (if it exists) when the object is created, and the %__destruct()% method when it is destroyed. </blurb> <example filename="obj_con_des5.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_con_des2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_con_des2.xml +++ presentations/slides/php5_intro/obj_con_des2.xml <slide title="Construct/Destruct"> <blurb> As with PHP 4, classes that extend other classes should call the parent's constructor within their own constructor. </blurb> <example filename="obj_con.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_con_des4.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_con_des4.php +++ presentations/slides/php5_intro/obj_con_des4.php <?php class foo { var $bar; function foo($val) { $this->bar = $val; } } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_con_des5.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_con_des5.php +++ presentations/slides/php5_intro/obj_con_des5.php <?php class foo { var $bar; function __construct($val) { $this->bar = $val; } function __destruct() { unset($this->bar); } } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_const.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_const.php +++ presentations/slides/php5_intro/obj_const.php <?php class foo { const file_name = __FILE__; } echo foo::file_name; // will print current file name ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_const.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_const.xml +++ presentations/slides/php5_intro/obj_const.xml <slide title="Class Constants"> <blurb> PHP 5 allows class specific constants, which works just like regular constants, but are limited to the scope of the given class. </blurb> <example filename="obj_const.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_dom.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_dom.php +++ presentations/slides/php5_intro/obj_dom.php <?php $dom = new domDocument('1.0'); $root = $dom->createElement('root'); // create new element foreach (array('foo', 'bar', 'baz') as $v) { $node = $dom->createElement($v); // create new sub-element $node->appendChild($dom->createTextNode($v)); // add value to element $root->appendChild($node); // append sub-element to root element } $dom->appendChild($root); // add root node to document $xml = $dom->saveXML(); // output XML echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml))); ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_exception.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_exception.php +++ presentations/slides/php5_intro/obj_exception.php <?php try { /* begin exception block */ $fp = fopen(__FILE__, "r"); if (!$fp) { /* throw exception, error occurred */ throw new Exception('no such file', 9); } } catch (Exception $e) { /* what to do on error (thrown exception) */ echo $e->getCode(); // error code echo $e->getFile(); // file where exception was thrown echo $e->getLine(); // line on which exception was thrown echo $e->getMessage(); // error message print_r($e->getTrace()); // print backtrace } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_exceptions.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_exceptions.xml +++ presentations/slides/php5_intro/obj_exceptions.xml <slide title="Exceptions"> <image filename="different.jpg" align="right" /> <blurb> PHP 5 introduces exceptions using a Java-like syntax. All exceptions extend the standard %Exception% class, meaning that you can create your own custom exceptions. </blurb> <example filename="obj_exception.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_final.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_final.php +++ presentations/slides/php5_intro/obj_final.php <?php final class foo { function do_something() {} } class bar extends foo {} // won't work, fatal error class baz { final function foo() {} function bar() {} } class foo2 extends baz { function bar() {} } // will work class foo3 extends baz { function foo() {} } // will not work ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_final.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_final.xml +++ presentations/slides/php5_intro/obj_final.xml <slide title="Final Classes/Methods"> <blurb> Classes and methods can be specified as %final% that will disallow classes to be extended and methods to be overloaded. </blurb> <example filename="obj_final.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_get_set.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_get_set.php +++ presentations/slides/php5_intro/obj_get_set.php <?php class foo { private $int_data = array(); function __get($var_name) { return $this->int_data[$var_name]; } function __set($var_name, $value) { $this->int_data[$var_name] = urlencode($value); } } $a = new foo(); $a->bar = "random value"; echo $a->bar; // will print random+value ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_get_set.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_get_set.xml +++ presentations/slides/php5_intro/obj_get_set.xml <slide title="Getter and Setter"> <blurb> PHP 5 objects support special %__get()% and %__set()% methods to access "virtual" properties that do not actually existing, but instead are emulated existing data. </blurb> <example filename="obj_get_set.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_indirect.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_indirect.php +++ presentations/slides/php5_intro/obj_indirect.php <?php class foo { public $bar = 3; function baz() { echo $this->bar; } } class bar { public $o; function __construct() { $this->o = new foo(); } } $a = new bar(); $a->o->baz(); // will print 3 echo $a->o->bar; // will also print 3 /* in PHP 4 this would not be possible and require the following kludge */ $tmp =& $a->o; $tmp->baz(); echo $tmp->bar; ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_indirect.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_indirect.xml +++ presentations/slides/php5_intro/obj_indirect.xml <slide title="Indirect Referencing"> <blurb> PHP 5 permits access to properties and methods of an object that is stored inside in another object. In PHP 4 this required assignment of the object to separate variables. </blurb> <example filename="obj_indirect.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_interface.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_interface.php +++ presentations/slides/php5_intro/obj_interface.php <?php interface read_file { function open($file_name); function read($bytes); function close(); } class rf implements read_file { private $fp; function open($file_name) { $this->fp = fopen($file_name, "r"); } function read($bytes) { return fread($this->fp, $bytes); } function close() { fclose($this->fp); } } $f = new rf(); /* ensure that object inside $ implements read_file interface */ if ($f instanceof read_file) { $f->open(__FILE__); echo $f->read(4); $f->close(); } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_interface.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_interface.xml +++ presentations/slides/php5_intro/obj_interface.xml <slide title="Interfaces"> <blurb> You can now define object interfaces, which is a way to ensure that a given class provides a certain set of functions you can rely on elsewhere. </blurb> <example filename="obj_interface.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_method_over.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_method_over.php +++ presentations/slides/php5_intro/obj_method_over.php <?php class math { function __call($name, $args) { switch ($name) { case 'add': return array_sum($args); case 'subtract': $val = array_shift($args); foreach ($args as $v) $val /= $v; return $val; } } } $m = new math(); echo $m->add(1,2); // will print 3 echo $m->subtract(8,2); // will print 4 ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_method_over.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_method_over.xml +++ presentations/slides/php5_intro/obj_method_over.xml <slide title="Dynamic Methods"> <blurb> You can also create "virtual" methods that will be handled via the special %__call()% method. </blurb> <example filename="obj_method_over.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ppp.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ppp.php +++ presentations/slides/php5_intro/obj_ppp.php <?php class foo { public $foo=1; // everyone can access private $bar=2; // can only be accessed by the class internally protected $baz=3; // can be accessed by the class internally & any extending classes function p1() { echo $this->foo . $this->bar . $this->baz; } } class foo_ex extends foo { function p2() { echo $this->foo . $this->bar . $this->baz; } } $a = new foo(); echo $a->p1(); // will print 123 $b = new foo_ex(); echo $b->p2(); // will print 13 + notice about unknown property foo_ex::$bar // accessing private/protected properties directly will result is a E_ERROR (fatal error) echo $a->foo . $a->bar . $a->baz; ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ppp.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ppp.xml +++ presentations/slides/php5_intro/obj_ppp.xml <slide title="PPP"> <blurb> PHP 5 supports %public%, %private% and %protected% properties. The PHP 4 style %var% are treated as %public%, but will raise an E_STRICT warning when used. </blurb> <example filename="obj_ppp.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ppp2.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ppp2.php +++ presentations/slides/php5_intro/obj_ppp2.php <?php class foo { public function p() {} // everyone can use private function p2() {} // only class foo may use internally protected function p3() {} // only class foo and it's extender can use } class foo_ex extends foo { function foo_ex() { $this->p2(); } } $a = new foo(); $a->p3(); // fatal error $b = new foo_ex(); // will fail with fatal error ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ppp2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ppp2.xml +++ presentations/slides/php5_intro/obj_ppp2.xml <slide title="PPP"> <blurb> Object methods can also be designated as %public%, %private% and %protected%. Methods without specific designation are assumed to be %public%. </blurb> <example filename="obj_ppp2.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ref.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ref.php +++ presentations/slides/php5_intro/obj_ref.php <?php class foo { var $foo = 1, $bar = 10; function baz($val) { $this->bar *= $val; } } function mod_foo($foo) { $foo->baz(10); $foo->foo = 123; } $a = new foo(); mod_foo($a); echo $a->bar . "<br />"; // PHP4: 10 PHP5: 100 echo $a->foo . "<br />"; // PHP4: 1 PHP5: 123 ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ref.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ref.xml +++ presentations/slides/php5_intro/obj_ref.xml <slide title="Object References"> <blurb> In ZE / PHP 4 objects were passed by reference, so when variables containing objects were passed to functions a local copy of the object was made for the function. </blurb> <example filename="obj_ref.php" fontsize="2em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ref2.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ref2.php +++ presentations/slides/php5_intro/obj_ref2.php <?php class foo { var $bar = 10; function baz($val) { global $foo2; $foo2 = $this; $this->bar *= $val; } } $a = new foo(); $foo3 = $a; $a->baz(2); var_dump($a->bar == $foo2->bar); // PHP4: False PHP5: True var_dump($a->bar == $foo3->bar); // PHP4: False PHP5: True ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_ref2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_ref2.xml +++ presentations/slides/php5_intro/obj_ref2.xml <slide title="Object References Cont."> <blurb> In PHP 5 anytime a variable containing an object is assigned to another variable it ends up being passed by reference. </blurb> <example filename="obj_ref2.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_simplexml.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_simplexml.php +++ presentations/slides/php5_intro/obj_simplexml.php <?php $xml = '<articles> <article id="1"> <title>Something Happened</title> <author>Random Person</author> </article> <article id="2"> <title>Something Else Happened</title> <author>Different Person</author> </article> </articles>'; /* load & parse XML string */ $art = simplexml_load_string($xml); foreach ($art as $article) { echo 'Id: ' . $article['id']; echo 'Title: ' . $article->title; echo 'Author: ' . $article->author; } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_static.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_static.php +++ presentations/slides/php5_intro/obj_static.php <?php class foo { static $bar = 123; static function baz() { return 456; } } echo foo::$bar; // will print 123 echo foo::baz(); // will print 456 ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_static.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_static.xml +++ presentations/slides/php5_intro/obj_static.xml <slide title="Static Methods/Properties"> <image filename="static.jpg" align="right" /> <blurb> You can specify methods &amp; properties as %static% that permits access to them from outside of the class. </blurb> <example filename="obj_static.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_tostring.php?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_tostring.php +++ presentations/slides/php5_intro/obj_tostring.php <?php class foo { public $vals = array('foo', 'bar', 'baz'); function __toString() { return implode(' ', $this->vals); } } $a = new foo(); echo $a; // will print "foo bar baz" ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/obj_tostring.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/obj_tostring.xml +++ presentations/slides/php5_intro/obj_tostring.xml <slide title="Objects as Strings"> <blurb> There is now a special method %__toString()% that can be used to allow objects to be safely used as strings. </blurb> <example filename="obj_tostring.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/revolution.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/revolution.xml +++ presentations/slides/php5_intro/revolution.xml <slide title="Revolutionary Changes"> <break /> <image filename="che.gif" align="right" /> <list fontsize="3em"> <bullet>OO Support Completely Rewritten.</bullet> <bullet>XML Support Rewritten/Updated/Improved.</bullet> <bullet>SQLite</bullet> <bullet>MySQLi</bullet> <bullet>Tidy</bullet> <bullet>Obsolete/Non-Working Extensions Dropped</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/simplexml.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/simplexml.xml +++ presentations/slides/php5_intro/simplexml.xml <slide title="SimpleXML"> <image filename="magician.gif" align="right" /> <blurb> SimpleXML is arguably the simplest and fastest way to parse XML documents that is natively available in PHP. </blurb> <example filename="obj_simplexml.php" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/soap.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/soap.xml +++ presentations/slides/php5_intro/soap.xml <slide title="SOAP"> <image filename="ivorysoap.gif" align="right" /> <blurb> The %SOAP% extension is a fast and fairly complete interface for creating and working with SOAP web-services. </blurb> <list title="Capabilities"> <bullet>WSDL Code Generation improved</bullet> <bullet>Schema Code Generation added!</bullet> <bullet>Less focus on RPC, more on Document messaging</bullet> <bullet>Smaller code base, easier to extend</bullet> <bullet>Streams API support</bullet> <bullet>Uses DOM, may use SimpleXML alternatively in the future</bullet> <bullet>Cleaner code, better organized</bullet> <bullet>Makes use of new OO support in PHP 5</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/soap_client.php?r=1.1&p=1 Index: presentations/slides/php5_intro/soap_client.php +++ presentations/slides/php5_intro/soap_client.php <?php // instantiate SOAP client object $client = new SoapObject("http://example.com/soap_server.php", "urn:Object"); echo $client->version(); // call version() method ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/soap_ex.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/soap_ex.xml +++ presentations/slides/php5_intro/soap_ex.xml <slide title="SOAP Server/Client"> <example title="Server" filename="soap_server.php" result="0" fontsize="1.5em" /> <example title="Client" filename="soap_client.php" result="0" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/soap_server.php?r=1.1&p=1 Index: presentations/slides/php5_intro/soap_server.php +++ presentations/slides/php5_intro/soap_server.php <?php class info { function version() { return php_version(); } function name() { return php_uname(); } } $server = new SoapServer("urn:Object"); // create SOAP server object $server->setClass('info'); // set available methods based on a class $server->handle(); // handle requests ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/spl_ex1.php?r=1.1&p=1 Index: presentations/slides/php5_intro/spl_ex1.php +++ presentations/slides/php5_intro/spl_ex1.php <?php /* create directory iterator based on current directory */ $dir = new DirectoryIterator(dirname(__FILE__)); while ($dir->valid()) { // while there are valid entries if ($dir->isFile()) { // check if we are dealing with a file /* print file name & it's size */ echo "Name: ".$dir->getFilename().", size: ".$dir->getSize()."<br />"; } $dir->next(); // move to next entry } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/spl_ex1.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/spl_ex1.xml +++ presentations/slides/php5_intro/spl_ex1.xml <slide title="Directory Iterator"> <example filename="spl_ex1.php" result="1" fontsize="1.5em" />z </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/spl_intro.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/spl_intro.xml +++ presentations/slides/php5_intro/spl_intro.xml <slide title="Standard PHP Library"> <blurb> %SPL% is a collection of interfaces and classes that are meant to solve standard problems. </blurb> <list type="Solutions"> <bullet>Directory iterator</bullet> <bullet>Recursive directory iterator</bullet> <bullet>SimpleXML iterator</bullet> <bullet>Ability to extend existing iterators</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/sqlite_ex.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/sqlite_ex.xml +++ presentations/slides/php5_intro/sqlite_ex.xml <slide title="SQLite OO Interface"> <example filename="sqlite_oo.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/sqlite_ex2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/sqlite_ex2.xml +++ presentations/slides/php5_intro/sqlite_ex2.xml <slide title="SQLite Procedural Interface"> <example filename="sqlite_proc.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/sqlite_intro.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/sqlite_intro.xml +++ presentations/slides/php5_intro/sqlite_intro.xml <slide title="SQLite"> <image filename="sqlite.gif" align="right" /> <blurb> Newest database extension with arguably the fastest interface between the database &amp; PHP. </blurb> <list type="Features"> <bullet>Bundled with PHP 5 (including library)</bullet> <bullet>Fast and easy interface to 'flatfiles'</bullet> <bullet>Implements most of SQL92</bullet> <bullet>Supports both OO and procedural API</bullet> <bullet>No daemon required</bullet> <bullet>Enabled by default</bullet> <bullet>Can use PHP to extend SQL language</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/sqlite_oo.php?r=1.1&p=1 Index: presentations/slides/php5_intro/sqlite_oo.php +++ presentations/slides/php5_intro/sqlite_oo.php <?php /* open connection to memory database */ $db = new SQLiteDatabase(":memory:"); /* execute a regular query */ $db->query("CREATE TABLE test(a,b)"); $db->query("INSERT INTO test VALUES('1','2')"); /* retrieve data using an unbuffered query */ $r = $db->unbufferedQuery("SELECT * FROM test", SQLITE_ASSOC); echo '<pre>'; /* use object iterators to retrieve the data, without any additional functions */ foreach ($r as $row) { print_r($row); } echo '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/sqlite_proc.php?r=1.1&p=1 Index: presentations/slides/php5_intro/sqlite_proc.php +++ presentations/slides/php5_intro/sqlite_proc.php <?php function encode($str) { return base64_encode(urlencode($str)); } $db = sqlite_open(":memory:"); // open database /* create my functions */ sqlite_create_function($db, 'p_enc', 'encode', 1); sqlite_create_function($db, 'p_md5', 'md5', 1); sqlite_query($db, "CREATE TABLE test(a,b)"); sqlite_query("INSERT INTO test VALUES(p_enc('1'),p_md5('2'))", $db); echo '<pre>'; print_r(sqlite_array_query($db, "SELECT * FROM test", SQLITE_NUM)); echo '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/standard.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/standard.xml +++ presentations/slides/php5_intro/standard.xml <slide title="Standard Functions"> <blurb> Aside from the new extensions and object related changes, a fair number of new functions were added as part of the standard functions extension. </blurb> <list title="New Functions"> <bullet>%file_put_contents()% - Quickly write or append to a file.</bullet> <bullet>%http_build_query()% - Generate URL-encoded query string.</bullet> <bullet>%convert_uudecode()% - Decode a uuencoded string.</bullet> <bullet>%convert_uuencode()% - Uuencode a string.</bullet> <bullet>%str_ireplace()% - Case insensitive equivalent of str_replace() .</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/standard2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/standard2.xml +++ presentations/slides/php5_intro/standard2.xml <slide title="Standard Functions Cont."> <list title="New Functions or Functionality"> <bullet>%strripos()% - Find position of last occurrence of a case-insensitive string in a string.</bullet> <bullet>%mkdir()% - Can now create directories recursively via an additional flag.</bullet> <bullet>%php_check_syntax()% - Validate syntax of PHP files.</bullet> <bullet>%headers_list()% - Get a list of headers sent to the browser.</bullet> <bullet>%time_nanosleep()% - Signal safe, high precision sleep function.</bullet> <bullet>A whole series of new array sorting and intersect functions.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/streams.php?r=1.1&p=1 Index: presentations/slides/php5_intro/streams.php +++ presentations/slides/php5_intro/streams.php <?php /* bind to port 11111 on local machine */ $sock = stream_socket_server('tcp://localhost:11111'); /* wait for user input */ while ($conn = stream_socket_accept($sock)) { $line = trim(fgets($conn)); // read user input fwrite($conn, "You wrote '$line'\n"); // print response } ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/streams2.php?r=1.1&p=1 Index: presentations/slides/php5_intro/streams2.php +++ presentations/slides/php5_intro/streams2.php <?php /* context options */ $opts = array( 'http' => array ( 'method' => "GET", 'header' => "Accept-language: en\r\n" ) ); /* create context resource */ $context = stream_context_create($opts); /* Send a request to php.net with specified context options * and filter the output via a filter that will remove HTML tags */ $data = file_get_contents( "php://filter/read=string.strip_tags/resource=http://www.php.net/", NULL, $context); ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/streams_ex1.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/streams_ex1.xml +++ presentations/slides/php5_intro/streams_ex1.xml <slide title="Streams Server"> <example filename="streams.php" result="0" fontsize="1.5em" /> <blurb> The experimental and rarely available %sockets% extension is made nearly absolete. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/streams_ex2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/streams_ex2.xml +++ presentations/slides/php5_intro/streams_ex2.xml <slide title="Streams Example #2"> <example filename="streams2.php" result="0" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/streams_intro.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/streams_intro.xml +++ presentations/slides/php5_intro/streams_intro.xml <slide title="Streams"> <image filename="stream.jpg" align="right" /> <blurb> While streams were introduced in PHP 4, it is in PHP 5 where the full capabilities of streams can be fully explored. </blurb> <list title="Changes"> <bullet>Nearly all functions that work with opening files/urls/sockets support contexts</bullet> <bullet>A number of built-in filters</bullet> <bullet>Can define new streams and filters in userspace</bullet> <bullet>Stream server support</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/thankyou.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/thankyou.xml +++ presentations/slides/php5_intro/thankyou.xml <slide title="Thank You!" fontsize="6em"> <blurb title="Find more information online..." /> <break /> <link marginleft="2em" leader="ZE2 Object Model Docs : ">http://www.php.net/zend-engine-2.php</link> <link marginleft="2em" leader="SQLite Homepage : ">http://www.sqlite.org/</link> <link marginleft="2em" leader="SimpleXML Docs : ">http://www.php.net/simplexml</link> <link marginleft="2em" leader="DOM Docs : ">http://www.php.net/dom</link> <break lines="2" /> <blurb title="Contact Me" /> <link fontsize="2.5em" marginleft="2em" leader="Ilia Alshanetsky ">ilia@php.net</link> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/tidy.php?r=1.1&p=1 Index: presentations/slides/php5_intro/tidy.php +++ presentations/slides/php5_intro/tidy.php <?php /* create tidy resource based on HTML string */ $a = tidy_parse_string("<HTML></HTML>"); tidy_clean_repair($a); // repair the given HTML $out = tidy_get_output($a); // get output echo nl2br(htmlspecialchars($out)); ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/tidy2.php?r=1.1&p=1 Index: presentations/slides/php5_intro/tidy2.php +++ presentations/slides/php5_intro/tidy2.php <?php /* tell tidy to automatically clean & repair output */ ini_set("tidy.clean_output", TRUE); /* set tidy output buffer, which will by default * automatically correct HTML output */ ob_start("ob_tidyhandler"); ?> <B>testing</I> http://cvs.php.net/co.php/presentations/slides/php5_intro/tidy_ex1.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/tidy_ex1.xml +++ presentations/slides/php5_intro/tidy_ex1.xml <slide title="Correct HTML w/Tidy"> <example filename="tidy.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/tidy_ex2.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/tidy_ex2.xml +++ presentations/slides/php5_intro/tidy_ex2.xml <slide title="Tidy Output Buffer"> <example filename="tidy2.php" result="0" fontsize="1.5em" />z <example title="Output" filename="tidy.txt" result="0" fontsize="1.5em" />z </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/tidy_intro.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/tidy_intro.xml +++ presentations/slides/php5_intro/tidy_intro.xml <slide title="Tidy Extension"> <image filename="tidy.jpg" align="right" /> <blurb> Tidy Extension is a wrapper around %libTidy% library, who's purpose is to clean, compact and convert between the various HTML variants. </blurb> <list title="Capabilities"> <bullet>Automatically repair malformed HTML</bullet> <bullet>Convert HTML 3 to HTML 4 to XHTML in a few lines of code</bullet> <bullet>Find and extract portions of HTML documents using OO</bullet> <bullet>Compact your page output using Tidy output buffer.</bullet> <bullet>Convert HTML tags to CSS whenever possible.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/titlepage.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/titlepage.xml +++ presentations/slides/php5_intro/titlepage.xml <slide template="titlepage" fontsize="6em"> <title>Welcome!</title> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/xml_intro.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/xml_intro.xml +++ presentations/slides/php5_intro/xml_intro.xml <slide title="PHP 5 &amp; XML"> <blurb> PHP 5 introduced a number of new XML extensions: %SOAP%, %SimpleXML%, %XSL%, %DOM% </blurb> <break /> <blurb> Older %XLST% and %DOMXML% were removed in favor of their newer counterparts. </blurb> <break /> <blurb> All XML extensions now use a single XML parsing library, LibXML2, unlike the older %Expat% this library is too big to bundle, however it is available by default on most systems. </blurb> <break /> <blurb> Additional XML extensions for PHP 5 are available from PECL repository (%XmlReader% &amp; %XmlWriter%) </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/xsl.php?r=1.1&p=1 Index: presentations/slides/php5_intro/xsl.php +++ presentations/slides/php5_intro/xsl.php <?php $xml = '<articles> <article id="1"> <title>Something Happened</title> <author>Random Person</author> </article> <article id="2"> <title>Something Else Happened</title> <author>Different Person</author> </article> </articles>'; $xsl = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" encoding="iso-8859-1" /> <xsl:template match="/"> <xsl:apply-templates select="//article"/> </xsl:template> <xsl:template match="article"> Title: <xsl:value-of select="title"/><br /> Author: <xsl:value-of select="author"/><br /> <hr /> </xsl:template> </xsl:stylesheet>'; /* load XSLT Stylesheet */ $xslDom = new domDocument(); $xslDom->loadXML($xsl); /* load XML data */ $xmlDom = new domDocument(); $xmlDom->loadXML($xml); $xsl = new XsltProcessor(); // instantiate XSLT processor $xsl->importStylesheet($xslDom); // load stylesheet echo $xsl->transformToXML($xmlDom); // perform the transformation & return HTML ?> http://cvs.php.net/co.php/presentations/slides/php5_intro/xsl.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/xsl.xml +++ presentations/slides/php5_intro/xsl.xml <slide title="XSL"> <image filename="recycle.gif" align="right" /> <blurb> %XSL% is the PHP 5 replacement for the older %XSLT% extension. </blurb> <list title="Powered By"> <bullet>Based on %libxslt%</bullet> <bullet>Uses %DOM% extension</bullet> </list> <list title="Features Include:"> <bullet>Simple API</bullet> <bullet>Supports most EXSLT (www.exslt.org)</bullet> <bullet>Can transform DOM to DOM, HTML, File or XML</bullet> <bullet>Allows PHP functions to be used as XSLT functions</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5_intro/xsl_ex.xml?r=1.1&p=1 Index: presentations/slides/php5_intro/xsl_ex.xml +++ presentations/slides/php5_intro/xsl_ex.xml <slide title="XSL Transformation"> <example filename="xsl.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom.xml +++ presentations/slides/php5xml/dom.xml <slide title="DOM Extension"> <blurb fontsize="3.5em"> DOM is not DOMXML. DOM extension has been written from scratch and strongly relies on the PHP 5 features &amp; capabilities. |FF0000|DOM is not compatible with DOMXML| </blurb> <list title="Features" fontsize="2.5em"> <bullet>DOM Level 3 Load and Save Support</bullet> <bullet>XPath</bullet> <bullet>Validation support</bullet> <bullet>NamedNodeMap support</bullet> <bullet>Complete Namespaces support</bullet> <bullet>Interop with SimpleXML and XSLT</bullet> <bullet>HTML</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_access.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_access.php +++ presentations/slides/php5xml/dom_access.php <?php $dom = new domDocument(); // create a DOM object $dom->load(dirname(__FILE__) . "/thedata.xml"); // load data from XML file /* access elements by tag name */ foreach ($dom->getElementsByTagName('title') as $node) { echo $node->nodeValue . "<br />"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_access.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_access.xml +++ presentations/slides/php5xml/dom_access.xml <slide title="Accessing Nodes w/DOM"> <example filename="dom_access.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_access2.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_access2.php +++ presentations/slides/php5xml/dom_access2.php <?php $xmlstring = '<?xml version="1.0" ?> <!DOCTYPE books [ <!ATTLIST book id ID #IMPLIED> ]> <books> <book id="1"> <title>Book 1</title> </book> <book id="2"> <title>Book 2</title> </book> </books>'; $dom = new domDocument(); /* load XML from string */ $dom->loadXML($xmlstring); /* get the node identified by id #2 */ $node = $dom->getElementById("2"); print trim($node->nodeValue); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_access2.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_access2.xml +++ presentations/slides/php5xml/dom_access2.xml <slide title="Accessing Nodes w/DOM"> <example filename="dom_access2.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_access3.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_access3.php +++ presentations/slides/php5xml/dom_access3.php <?php $dom = new domDocument(); $dom->load(dirname(__FILE__) . "/thedata.xml"); $root = $dom->documentElement; // <forum> foreach ($root->childNodes as $child) { if ($child->nodeType == XML_ELEMENT_NODE) { // <item> $id = $child->getAttribute("id"); // <item id="value"> echo "item #{$id}<br />"; foreach ($child->childNodes as $c2) { // item nodes if ($c2->nodeType == XML_ELEMENT_NODE) { // <title>, <link> echo "{$c2->nodeName} => {$c2->nodeValue}<br />"; } } } } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_access3.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_access3.xml +++ presentations/slides/php5xml/dom_access3.xml <slide title="DOM Tree"> <example filename="dom_access3.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_create.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_create.php +++ presentations/slides/php5xml/dom_create.php <?php $dom = new domDocument('1.0'); $root = $dom->createElement('root'); // create new element foreach (array('foo', 'bar', 'baz') as $v) { $node = $dom->createElement($v); // create new sub-element $node->appendChild($dom->createTextNode($v)); // add value to element $root->appendChild($node); // append sub-element to root element } $dom->appendChild($root); // add root node to document $xml = $dom->saveXML(); // output XML echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml))); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_create.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_create.xml +++ presentations/slides/php5xml/dom_create.xml <slide title="Creating XML with DOM"> <example filename="dom_create.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_html.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_html.php +++ presentations/slides/php5xml/dom_html.php <?php $dom = new DomDocument(); /* load HTML document (if it is not valid) */ @$dom->loadHTMLFile("http://" . $_SERVER['SERVER_ADDR'] . dirname($_SERVER['PHP_SELF']) . '/1'); $xp = new DomXpath($dom); /* use XPath to get the title of the */ $res = $xp->query("//title/text()"); echo $res->item(0)->nodeValue; ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_html.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_html.xml +++ presentations/slides/php5xml/dom_html.xml <slide title="DOM and HTML"> <example filename="dom_html.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_modify.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_modify.php +++ presentations/slides/php5xml/dom_modify.php <?php $dom = new domDocument('1.0'); $dom->load(dirname(__FILE__) . "/thedata.xml"); $new_item = $dom->createElement('item'); $new_item->setAttribute("id", 1234); // set attribute id for new item foreach (array('title', 'link', 'description') as $v) { $node = $dom->createElement($v); $node->appendChild($dom->createTextNode($v)); $new_item->appendChild($node); } // append entry to existing forum entries $dom->documentElement->appendChild($new_item); $xml = $dom->saveXML(); echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml))); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_modify.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_modify.xml +++ presentations/slides/php5xml/dom_modify.xml <slide title="Modify XML with DOM"> <example filename="dom_modify.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_validate.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_validate.php +++ presentations/slides/php5xml/dom_validate.php <?php $dom = new domDocument; $dom->load(dirname(__FILE__) . "/thedata.xml"); if (@$dom->validate()) { echo "Document is valid"; } else { echo "Document is invalid"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_validate.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_validate.xml +++ presentations/slides/php5xml/dom_validate.xml <slide title="DOM &amp; XML Validation"> <example filename="dom_validate.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_validate2.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_validate2.xml +++ presentations/slides/php5xml/dom_validate2.xml <slide title="DOM &amp; XML Validation"> <list fontsize="3.5em" title="DOM XML Validation Mechanisms"> <bullet>boolean attribute DOMDocument->validateOnParse</bullet> <bullet>boolean DOMDocument->validate()</bullet> <bullet>boolean DOMDocument->schemaValidate(string filename)</bullet> <bullet>boolean DOMDocument->schemaValidateSource(string xml)</bullet> <bullet>boolean DOMDocument->relaxNGValidate(string filename)</bullet> <bullet>boolean DOMDocument->relaxNGValidateSource(string xml)</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_xpath.php?r=1.1&p=1 Index: presentations/slides/php5xml/dom_xpath.php +++ presentations/slides/php5xml/dom_xpath.php <?php $dom = new domDocument(); $data = file_get_contents(dirname(__FILE__) . "/thedata.xml"); $dom->loadXML($data); // load data from XML string $xp = new DomXPath($dom); // create XPath object $res = $xp->query("//item/title"); // get title element echo $res->item(0)->nodeValue; // get data from 1st entry ?> http://cvs.php.net/co.php/presentations/slides/php5xml/dom_xpath.xml?r=1.1&p=1 Index: presentations/slides/php5xml/dom_xpath.xml +++ presentations/slides/php5xml/dom_xpath.xml <slide title="DOM &amp; XPath"> <example filename="dom_xpath.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/expat.php?r=1.1&p=1 Index: presentations/slides/php5xml/expat.php +++ presentations/slides/php5xml/expat.php <?php // Evil pres2 hackery $path = dirname(__FILE__); include("{$path}/expat_callback.inc.php"); $x = xml_parser_create(); // tag handler xml_set_element_handler($x, 'w_start_tag', 'w_end_tag'); // data handler xml_set_character_data_handler($x, 'w_data'); // always make tag names uppercase xml_parser_set_option($x, XML_OPTION_CASE_FOLDING, TRUE); // parse xml file xml_parse($x, file_get_contents("{$path}/thedata.xml")); // free memory xml_parser_free($x); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/expat_callback.inc.php?r=1.1&p=1 Index: presentations/slides/php5xml/expat_callback.inc.php +++ presentations/slides/php5xml/expat_callback.inc.php <?php class entry { public $title, $id, $link, $description; // temporary variable used to indicate current tag public $cur_tag; } function w_start_tag($x, $tag, $attr) { global $w; switch ($tag) { case 'ITEM': $w = new entry; $w->id = $attr['ID']; break; case 'TITLE': case 'LINK': case 'DESCRIPTION': $w->cur_tag = $tag; break; } } function w_end_tag($x, $tag) { global $w; if ($tag == 'DESCRIPTION') { echo "Title: <a href='{$w->link}'>{$w->title}</a><br />\n Body: {$w->description}<hr />"; unset($w); } } function w_data($x, $data) { global $w; // move along, nothing to see here if (!is_object($w)) return; switch ($w->cur_tag) { case 'TITLE': case 'LINK': case 'DESCRIPTION': $w->{strtolower($w->cur_tag)} .= trim($data); break; } } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/expat_struct.php?r=1.1&p=1 Index: presentations/slides/php5xml/expat_struct.php +++ presentations/slides/php5xml/expat_struct.php <?php $x = xml_parser_create(); // uppercase xml elements xml_parser_set_option($x, XML_OPTION_CASE_FOLDING, TRUE); // spaces begone!! xml_parser_set_option($x, XML_OPTION_SKIP_WHITE, TRUE); $data = file_get_contents(dirname(__FILE__) . '/thedata.xml'); xml_parse_into_struct($x, $data, $forum, $tags); xml_parser_free($x); // Woohooo, we're done! // count number of instances of a particular property to // determine the number of entries inside the XML file $num_elements = count($tags['DESCRIPTION']); for($i = 0; $i < $num_elements; $i++) { $title = $forum[$tags['TITLE'][$i]]['value']; $body = $forum[$tags['DESCRIPTION'][$i]]['value']; $link = $forum[$tags['LINK'][$i]]['value']; echo "Title: <a href='{$link}'>{$title}</a><br /> Body: {$body}<hr />"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/libs.xml?r=1.1&p=1 Index: presentations/slides/php5xml/libs.xml +++ presentations/slides/php5xml/libs.xml <slide title="LibXML2 vs Expat"> <blurb> Aside from the addition of the new XML parsing extensions, in PHP 5 the underlying XML library was changed as well. </blurb> <list title="LibXML2 the Good"> <bullet>Feature complete</bullet> <bullet>Active development</bullet> <bullet>Very fast for DOM</bullet> </list> <list title="and the Bad"> <bullet>Significantly larger then Expat (not bundled with PHP)</bullet> <bullet>Slightly slower for SAX</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/parsing_xml.xml?r=1.1&p=1 Index: presentations/slides/php5xml/parsing_xml.xml +++ presentations/slides/php5xml/parsing_xml.xml <slide> <title>XML Processing</title> <image filename="gears.gif" align="center" /> <blurb><![CDATA[ <table class="index" border="0" cellpadding=5 align="center" > <tr> <th width="50%" align="left" style="font-size: 2em;">DOM</th> <th width="50%" align="left" style="font-size: 2em;">SAX</th> </tr> <tr> <td style="font-size: 1.8em; color: blue;">Good for small documents</td> <td style="font-size: 1.8em; color: green;">Event driven, good for large documents</td> <tr> <tr> <td style="font-size: 1.8em; color: blue;">Simpler to use (less code)</td> <td style="font-size: 1.8em; color: green;">More memory efficient (if dom tree is not built)</td> <tr> <tr> <td style="font-size: 1.8em; color: blue;">Easier to generate XML</td> <td style="font-size: 1.8em; color: green;">Faster for remote sources.</td> </tr> </table> ]]></blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/php_xml.xml?r=1.1&p=1 Index: presentations/slides/php5xml/php_xml.xml +++ presentations/slides/php5xml/php_xml.xml <slide> <title>PHP 5 and XML</title> <image filename="choices.jpg" align="right" /> <blurb> In PHP 5 working with XML can be done in any number of ways, via a whole series of extensions. </blurb> <list> <bullet>XML extension</bullet> <bullet>DOM</bullet> <bullet>XML-RPC</bullet> <bullet>Simplexml</bullet> <bullet>SOAP</bullet> <bullet>XML Reader (PECL)</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/php_xml2.xml?r=1.1&p=1 Index: presentations/slides/php5xml/php_xml2.xml +++ presentations/slides/php5xml/php_xml2.xml <slide title="Extension Functionality"> <blurb> The PHP's XML extensions can be split into 4 categories, based on their functionality and backend processing mechanisms. </blurb> <image filename="extension.jpg" align="right" /> <list title="Document Object Model (DOM)" fontsize="2em"> <bullet>SimpleXML</bullet> <bullet>DOM |00AA00|Evolution of domxml in PHP 4|</bullet> </list> <list title="Simple API for XML (SAX)" fontsize="2em"> <bullet>XML |00AA00|Same as in PHP 4|</bullet> <bullet>XMLReader</bullet> </list> <list title="Web Services" fontsize="2em"> <bullet>SOAP</bullet> <bullet>XML-RPC |00AA00|Same as in PHP 4|</bullet> </list> <list title="XML Transformation" fontsize="2em"> <bullet>XSL |00AA00|Evolution of XLST in PHP 4|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/sax.xml?r=1.1&p=1 Index: presentations/slides/php5xml/sax.xml +++ presentations/slides/php5xml/sax.xml <slide> <title>SAX Callbacks</title> <example filename="expat_callback.inc.php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/sax2.xml?r=1.1&p=1 Index: presentations/slides/php5xml/sax2.xml +++ presentations/slides/php5xml/sax2.xml <slide> <title>SAX Glue</title> <example filename="expat.php" fontsize="1.4em" /> <blurb> End Result: </blurb> <example filename="expat.php" hide="1" result="1" type="html" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/sax3.xml?r=1.1&p=1 Index: presentations/slides/php5xml/sax3.xml +++ presentations/slides/php5xml/sax3.xml <slide> <title>SAX Structured Access</title> <blurb> A simpler way to access XML structures (SAX for lazy people). <![CDATA[<br />]]>This is pretty much a DOM emulation mode. </blurb> <example filename="expat_struct.php" result="1" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml.php?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml.php +++ presentations/slides/php5xml/simplexml.php <?php /* load a xml file to memory & parse it */ $xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml'); /* We are done, output time */ foreach ($xml->item as $msg) { echo "Title: <a href='{$msg->link}'>{$msg->title}</a> (id: {$msg['id']}) <br />Body: {$msg->description}<hr />"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml.xml?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml.xml +++ presentations/slides/php5xml/simplexml.xml <slide title="SimpleXML"> <image filename="wizardry.jpg" align="right" /> <blurb fontsize="3em"> Sterling Hughes: "XML is the solution to all your problems; SimpleXML ensures it isn't the root of your problems!" </blurb> <list fontsize="2.5em"> <bullet>New in PHP 5 (enabled by default)</bullet> <bullet>Object Oriented approach to XML Documents</bullet> <bullet>Really useful for well structured XML</bullet> <bullet>Supports XPath for all sorts of tricks</bullet> <bullet>Can write to attributes</bullet> <bullet>|FF0000|Fast and Simple to use|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_dom.php?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_dom.php +++ presentations/slides/php5xml/simplexml_dom.php <?php $xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml'); /* convert SimpleXML to DOM object */ $dom = dom_import_simplexml($xml); /* convert from DOM object back to SimpleXML */ $xml2 = simplexml_import_dom($dom); /* confirm that no data was lost */ echo ($xml2->asXML() == $xml->asXML()); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_dom.xml?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_dom.xml +++ presentations/slides/php5xml/simplexml_dom.xml <slide title="SimpleXML &amp; DOM"> <example filename="simplexml_dom.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_ex.xml +++ presentations/slides/php5xml/simplexml_ex.xml <slide title="SimpleXML in Action"> <example filename="simplexml.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_mod.php?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_mod.php +++ presentations/slides/php5xml/simplexml_mod.php <?php $xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml'); /* modify all item ids and titles */ foreach ($xml->item as $msg) { $msg['id'] += 1000; // increase id by 1000 $msg->title .= ' ( was modified ) '; // indicate that data was changed } /* output modified XML document */ echo '<pre>' . htmlspecialchars($xml->asXML()) . '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_mod.xml?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_mod.xml +++ presentations/slides/php5xml/simplexml_mod.xml <slide title="SimpleXML &amp; XPath"> <example filename="simplexml_mod.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_prob.php?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_prob.php +++ presentations/slides/php5xml/simplexml_prob.php <?php $html = '<html><body>Some random <strong>Bold</strong> and <em>italics</em> text.</body></html>'; $xml = simplexml_load_string($html); echo $xml->body . "<br />"; echo $xml->body->strong . "<br />"; echo $xml->body->em . "<br />"; ?> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_problem.xml?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_problem.xml +++ presentations/slides/php5xml/simplexml_problem.xml <slide title="SimpleXML is not Perfect"> <image filename="imperfect.jpg" align="right" /> <break /> <example filename="simplexml_prob.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_xpath.php?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_xpath.php +++ presentations/slides/php5xml/simplexml_xpath.php <?php /* load XML document from a string */ $xml = simplexml_load_string(file_get_contents(dirname(__FILE__) . '/thedata.xml')); /* access the 1st <title> from the document */ echo array_shift($xml->xpath("//item[1]/title")) . "<br />"; /* get data from item entry with an id of 10149 */ echo '<pre>'; print_r($xml->xpath("//item[@id=10149]")); echo '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml/simplexml_xpath.xml?r=1.1&p=1 Index: presentations/slides/php5xml/simplexml_xpath.xml +++ presentations/slides/php5xml/simplexml_xpath.xml <slide title="SimpleXML &amp; XPath"> <example filename="simplexml_xpath.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap.xml +++ presentations/slides/php5xml/soap.xml <slide title="SOAP"> <blurb fontsize="4em">The road to hell is paved with good intentions.</blurb> <image filename="soap.gif" align="right" /> <list> <bullet>Formerly known as Simple Object Access Protocol.</bullet> <bullet>A messaging format primary used for RPC.</bullet> <bullet>Uses XML.</bullet> <bullet>View Source protocol.</bullet> </list> <list title="Brief History"> <bullet>Initial release, Babylon 2800 B.C</bullet> <bullet>SOAP 1.0, Microsoft 1999</bullet> <bullet>SOAP 1.1, IBM and Microsoft 2000</bullet> <bullet>SOAP 1.2, W3C present time</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_client.php?r=1.1&p=1 Index: presentations/slides/php5xml/soap_client.php +++ presentations/slides/php5xml/soap_client.php <?php $client = new SoapObject("http://example.com/server.php", "urn:Object"); echo $client->ls("/vmlinuz*"); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_client.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_client.xml +++ presentations/slides/php5xml/soap_client.xml <slide title="SOAP WSDL Client"> <example filename="soap_wdsl_client.php" hide="0" result="0" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_cons_pros.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_cons_pros.xml +++ presentations/slides/php5xml/soap_cons_pros.xml <slide title="SOAP Summary"> <list fontsize="4em" title="Advantages"> <bullet>PHP API is very easy to use</bullet> <bullet>Ability to customize every portion of the message</bullet> <bullet>Fully Buzzword Compliant</bullet> </list> <list fontsize="4em" title="Disadvantages"> <bullet>Not yet completely stable</bullet> <bullet>Difficult to understand internals</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_doc.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_doc.xml +++ presentations/slides/php5xml/soap_doc.xml <slide title="SOAP Document Rules"> <blurb fontsize="4.0em"> A SOAP Document must meet the following requirements </blurb> <list fontsize="4.0em"> <bullet>Must have a top-level %Envelope% namespaced to %http://schemas.xmlsoap.org/soap/envelope/%</bullet> <bullet>Must contain %Body% element</bullet> <bullet>May contain an optional %Header% and %Fault% elements</bullet> <bullet>The contents of %Header% and %Body% must be properly namespaced</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_doc_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_doc_ex.xml +++ presentations/slides/php5xml/soap_doc_ex.xml <slide title="SOAP Document"> <example title="SOAP Document"><![CDATA[<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Header> <m:Trans xmlns:m="http://www.example.com/header/" soap:mustUnderstand="1"> 234 </m:Trans> </soap:Header> <soap:Body> <soap:Fault> </soap:Fault> <purge xmlns="http://fud.prohost.org/message"> <documentid>298</documentid> </purge> </soap:Body> </soap:Envelope>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_fault_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_fault_ex.xml +++ presentations/slides/php5xml/soap_fault_ex.xml <slide title="SOAP Fault"> <example><![CDATA[<?xml version="1.0"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:m="http://www.example.org/timeouts" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <env:Body> <env:Fault> <env:Code> <env:Value>env:Sender</env:Value> <env:Subcode> <env:Value>m:MessageTimeout</env:Value> </env:Subcode> </env:Code> <env:Reason> <env:Text xml:lang="en">Sender Timeout</env:Text> </env:Reason> <env:Detail> <m:MaxTime>P5M</m:MaxTime> </env:Detail> </env:Fault> </env:Body> </env:Envelope>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_server.php?r=1.1&p=1 Index: presentations/slides/php5xml/soap_server.php +++ presentations/slides/php5xml/soap_server.php <?php class filesystem { function ls($dir) { return shell_exec("ls ".escapeshellarg($dir)); } } // PECL::SOAP $server = new SoapServer("urn:Object"); $server->setClass('filesystem'); $server->handle(); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_server.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_server.xml +++ presentations/slides/php5xml/soap_server.xml <slide title="SOAP Server/Client"> <example filename="soap_server.php" fontsize="1.4em" title="SOAP Server" /> <example filename="soap_client.php" fontsize="1.4em" title="SOAP Client" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_wdsl_client.php?r=1.1&p=1 Index: presentations/slides/php5xml/soap_wdsl_client.php +++ presentations/slides/php5xml/soap_wdsl_client.php <?php /* create a new SOAP client based on given wsdl file */ $client = new SoapClient("WhoisData.wsdl"); /* run a whois query by calling getWhoisData method provided by * whois server and described by WhoisData.wsdl */ $result = $client->getWhoisData( /* create parameters needed for the request */ new SoapParam("php.net", "domain"), new SoapParam("1234", "clientID"), new SoapParam("emailAddress", "user@domain.com") ); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/soap_wsdl.xml?r=1.1&p=1 Index: presentations/slides/php5xml/soap_wsdl.xml +++ presentations/slides/php5xml/soap_wsdl.xml <slide title="WSDL"> <blurb fontsize="3em" title="Web Service Description Language (WSDL)"> Machine readable description (XML) of a web service. Used here to define server's methods and parameters. </blurb> <example filename="wsdl.php" hide="1" result="1" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/thankyou.xml?r=1.1&p=1 Index: presentations/slides/php5xml/thankyou.xml +++ presentations/slides/php5xml/thankyou.xml <slide title="Thank You!" fontsize="6em"> <blurb title="Find more information online..." /> <break /> <link marginleft="2em" leader="SimpleXML Docs : ">http://www.php.net/simplexml</link> <link marginleft="2em" leader="DOM Docs : ">http://www.php.net/dom</link> <link marginleft="2em" leader="XSL Docs : ">http://www.php.net/xsl</link> <link marginleft="2em" leader="SOAP Docs : ">http://www.php.net/soap</link> <break lines="2" /> <blurb title="Contact Me" /> <link fontsize="2.5em" marginleft="2em" leader="Ilia Alshanetsky ">ilia@php.net</link> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/thedata.php?r=1.1&p=1 Index: presentations/slides/php5xml/thedata.php +++ presentations/slides/php5xml/thedata.php <?php echo '<pre>' . htmlspecialchars(' <forum uri="http://fud.prohost.org/forum/index.php"> <item id="10084"> <title>Binary Protocols vs XML</title> <link>http://fud.prohost.org/forum/index.php/m/10084</link> <description>Why does everyone insist on using XML?</description> </item> <item id="10149"> <title>How do I post messages?</title> <link>http://fud.prohost.org/forum/index.php/m/10149</link> <description>I can post messages, help!</description> </item> </forum> ') . '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml/thedata.xml?r=1.1&p=1 Index: presentations/slides/php5xml/thedata.xml +++ presentations/slides/php5xml/thedata.xml <?xml version="1.0"?> <forum uri="http://fud.prohost.org/forum/index.php"> <item id="10084"> <title>Binary Protocols vs XML</title> <link>http://fud.prohost.org/forum/index.php/m/10084</link> <description>Why does everyone insist on using XML?</description> </item> <item id="10149"> <title>How do I post messages?</title> <link>http://fud.prohost.org/forum/index.php/m/10149</link> <description>I can post messages, help!</description> </item> </forum> http://cvs.php.net/co.php/presentations/slides/php5xml/titlepage.xml?r=1.1&p=1 Index: presentations/slides/php5xml/titlepage.xml +++ presentations/slides/php5xml/titlepage.xml <slide template="titlepage" fontsize="6em"> <title>Welcome!</title> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/whatis.xml?r=1.1&p=1 Index: presentations/slides/php5xml/whatis.xml +++ presentations/slides/php5xml/whatis.xml <slide> <title>What is XML?</title> <blurb align="center" fontsize="6em"> What is XML? </blurb> <image filename="confused.gif" align="center" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/whyxml.xml?r=1.1&p=1 Index: presentations/slides/php5xml/whyxml.xml +++ presentations/slides/php5xml/whyxml.xml <slide> <title>Why Use XML?</title> <blurb> There are a number of good reasons to use XML, however it is important to note that XML is not a "one size fit all" solution. </blurb> <image filename="buzzword.gif" align="right" /> <list> <bullet>Completely platform independent.</bullet> <bullet>Most languages can easily parse it.</bullet> <bullet>Fairly simple syntax.</bullet> <bullet>Not limited to a particular protocol.</bullet> <bullet>Unicode Support</bullet> <bullet>Buzzword compliance.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/wsdl.php?r=1.1&p=1 Index: presentations/slides/php5xml/wsdl.php +++ presentations/slides/php5xml/wsdl.php <pre> <?php echo htmlspecialchars(file_get_contents(dirname(__FILE__) . "/WhoisData.wsdl")); ?> </pre> http://cvs.php.net/co.php/presentations/slides/php5xml/xml.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xml.xml +++ presentations/slides/php5xml/xml.xml <slide> <title>What is it, really?</title> <blurb> XML - eXtensible Markup Language - a structured way to present information. </blurb> <example filename="thedata.php" hide="1" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlread.php?r=1.1&p=1 Index: presentations/slides/php5xml/xmlread.php +++ presentations/slides/php5xml/xmlread.php <?php // create XMLReader object $reader = new XMLReader(); // open XML file, to open strings use $reader->XML($string) $reader->open(dirname(__FILE__) . '/thedata.xml'); $id = $link = $description = $title = $curval = ''; // loop through the elements while ($reader->read()) { switch ($reader->nodeType) { case XMLREADER_ELEMENT: /* fetch element name */ $curval = $reader->localName; /* check for attributes */ if ($reader->hasAttributes) { /* move to 1st attribute */ $attr = $reader->moveToFirstAttribute(); while ($attr) { ${$reader->name} = $reader->value; /* move to next attribute */ $attr = $reader->moveToNextAttribute(); } } break; case XMLREADER_TEXT: /* fetch element value */ ${$curval} = $reader->value; break; case XMLREADER_END_ELEMENT: /* element end */ /* if end of <item>, print info */ if ($reader->localName == 'item') { echo "Title: <a href='{$link}'>{$title}</a><br /> Body: {$description}<hr />"; } break; } } ?> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlread_valid1.php?r=1.1&p=1 Index: presentations/slides/php5xml/xmlread_valid1.php +++ presentations/slides/php5xml/xmlread_valid1.php <?php $reader = new XMLReader(); /* load xml document as a string */ $reader->XML(file_get_contents(dirname(__FILE__) . '/thedata.xml')); /* tell the parser to perform syntax validation */ $reader->setParserProperty(XMLREADER_VALIDATE, TRUE); // loop until end of document // @ blocks the parser errors (missing DTD in this case) while (@$reader->read()); echo "XML document is: " . ($reader->isValid() ? '' : ' not') . " valid."; ?> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlreader.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlreader.xml +++ presentations/slides/php5xml/xmlreader.xml <slide title="XmlReader"> <blurb fontsize="5em" align="center"> XmlReader </blurb> <image filename="reader.jpg" align="center" /> <list fontsize="3em"> <bullet>Very new extension (in PECL)</bullet> <bullet>a so called Pull Parser</bullet> <bullet>API derived from C# XmlTextReader</bullet> <bullet>A replacement for SAX</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlreader_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlreader_ex.xml +++ presentations/slides/php5xml/xmlreader_ex.xml <slide title="XmlReader in Action"> <example filename="xmlread.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlreader_sum.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlreader_sum.xml +++ presentations/slides/php5xml/xmlreader_sum.xml <slide title="XmlReader Summary"> <list fontsize="3em" title="XmlReader Summary"> <bullet>A replacement for SAX</bullet> <bullet>Support for XML &amp; RelaxNG Validation</bullet> <bullet>Simple and Proven API</bullet> <bullet>In most cases faster then SAX (XML extension)</bullet> <bullet>|FF0000|Very new &amp; Experimental|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlreader_validation.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlreader_validation.xml +++ presentations/slides/php5xml/xmlreader_validation.xml <slide title="XmlReader XML Validation"> <blurb> Aside from parsing XML documents, XmlReader can also be used to quickly validate them. </blurb> <example filename="xmlread_valid1.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlreader_vs_sax.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlreader_vs_sax.xml +++ presentations/slides/php5xml/xmlreader_vs_sax.xml <slide title="XmlReader vs SAX"> <image filename="boxing.jpg" align="center" /> <list fontsize="3.5em"> <bullet>Sax is Event based</bullet> <bullet>XmlReader is cursor based</bullet> <bullet>XmlReader has support for namespaces, validation and entities</bullet> <bullet>Both do not load the whole document into memory</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc.xml +++ presentations/slides/php5xml/xmlrpc.xml <slide title="XMLRPC"> <break /> <blurb fontsize="3em"> XMLRPC allows a computer to execute functions and class methods on another computer with any given arguments. </blurb> <image filename="xmlrpc.jpg" align="center" /> <blurb fontsize="3em"> Primarily uses HTTP for transporting requests that are encoded using XML. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_client.php?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_client.php +++ presentations/slides/php5xml/xmlrpc_client.php <?php // generate request $request = xmlrpc_encode_request("ls", array("-1", "--color=no", dirname(__FILE__))); // we encode the request to make it safe to pass via GET $request = base64_encode($request); // pres2 hackery $url = preg_replace("!.*/presentations/!", "/presentations/", __FILE__); $url = str_replace('xmlrpc_client.php', 'xmlrpc_server.php', $url); // we now need to submit the request to the server $response = file_get_contents("http://{$_SERVER['HTTP_HOST']}{$url}?query={$request}"); // decode XML response into something PHP can understand $response = xmlrpc_decode($response); echo nl2br($response); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_client.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_client.xml +++ presentations/slides/php5xml/xmlrpc_client.xml <slide title="XMLRPC Client"> <example filename="xmlrpc_client.php" result="0" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_cons_pros.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_cons_pros.xml +++ presentations/slides/php5xml/xmlrpc_cons_pros.xml <slide title="XMLRPC Cons &amp; Pros"> <list title="Why use XMLRPC?"> <bullet>Easy to understand, implement and debug</bullet> <bullet>Quite fast</bullet> <bullet>Stable</bullet> <bullet>Can be emulated with PEAR</bullet> </list> <list title="XML-RPC sucks because..."> <bullet>No new functionality being added</bullet> <bullet>Not completely buzzword compliant</bullet> <bullet>Very few big providers use XMLRPC</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_request.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_request.xml +++ presentations/slides/php5xml/xmlrpc_request.xml <slide title="XMLRPC Request Source"> <example title="Request"><![CDATA[<?xml version="1.0"?> <methodCall> <methodName>package.info</methodName> <params> <param> <value> <string>XML_RPC</string> </value> </param> </params> </methodCall>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_response.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_response.xml +++ presentations/slides/php5xml/xmlrpc_response.xml <slide title="XMLRPC Response Source"> <example title="Response"><![CDATA[<?xml version="1.0" encoding="iso-8859-1"?> <methodResponse> <params> <param> <value> <struct> <member> <name>packageid</name> <value> <string>17</string> </value> </member> <member> <name>name</name> <value> <string>XML_RPC</string> </value> </member> </struct> </value> </param> </params> </methodResponse>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_server.php?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_server.php +++ presentations/slides/php5xml/xmlrpc_server.php <?php // some functions to be exposed via XML-RPC function uptime_func($method_name, $params, $app_data) { return shell_exec('uptime'); } function ls_func($method_name, $params, $app_data) { $args = ''; foreach ($params as $parm) { $args .= escapeshellarg($parm) . ' '; } return shell_exec("ls {$args}"); } // create server $xmlrpc_server = xmlrpc_server_create(); // Register PHP functions as XML-RPC methods xmlrpc_server_register_method($xmlrpc_server, "ls", "ls_func"); xmlrpc_server_register_method($xmlrpc_server, "uptime", "uptime_func"); // execute XML-RPC method based on the request which can be found inside // _GET['query']. The returned response is immediately returned to the user echo xmlrpc_server_call_method($xmlrpc_server, base64_decode($_GET['query']), NULL); // free resources xmlrpc_server_destroy($xmlrpc_server); ?> http://cvs.php.net/co.php/presentations/slides/php5xml/xmlrpc_server.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xmlrpc_server.xml +++ presentations/slides/php5xml/xmlrpc_server.xml <slide title="XMLRPC Server"> <example filename="xmlrpc_server.php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xpath.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xpath.xml +++ presentations/slides/php5xml/xpath.xml <slide title="XPath"> <image filename="xpath.jpg" align="right" /> <list title="XPath" fontsize="3.5em"> <bullet>W3C Standard</bullet> <bullet>XPath is a language for addressing parts of an XML document</bullet> <bullet>Supported by many programming languages</bullet> <bullet>Very important for XSLT</bullet> <bullet>Accesses an XML document similar to a filesystem</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xslt.php?r=1.1&p=1 Index: presentations/slides/php5xml/xslt.php +++ presentations/slides/php5xml/xslt.php <?php $path = dirname(__FILE__) . '/'; /* load XSLT Stylesheet as if it were a regular XML file via DOM extension */ $xslDom = new domdocument; $xslDom->load($path . 'forum.xsl'); /* load the actual XML data we will use to populate the stylesheet */ $xmlDom = new domdocument; $xmlDom->load($path . 'thedata.xml'); $xsl = new XsltProcessor; // instantiate XSLT processor $xsl->importStylesheet($xslDom); // load stylesheet echo $xsl->transformToXML($xmlDom); // perform the transformation & return HTML ?> http://cvs.php.net/co.php/presentations/slides/php5xml/xslt.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xslt.xml +++ presentations/slides/php5xml/xslt.xml <slide title="XSLT via XSL Extension"> <image filename="transformer.gif" align="right" /> <blurb fontsize="3em"> XSLT is a language designed to facilitate XML transformations, in XML itself. </blurb> <list> <bullet>Uses DOM extension</bullet> <bullet>Supports most EXSLT (www.exslt.org)</bullet> <bullet>Transform DOM to DOM, HTML, File or XML</bullet> </list> <break /> <blurb fontsize="2.5em"> Replacement for XSLT extension in PHP 4. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xslt_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xslt_ex.xml +++ presentations/slides/php5xml/xslt_ex.xml <slide title="XSLT Transformation"> <example filename="xslt.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml/xslt_stylesheet.xml?r=1.1&p=1 Index: presentations/slides/php5xml/xslt_stylesheet.xml +++ presentations/slides/php5xml/xslt_stylesheet.xml <slide title="XSLT Stylesheet"> <example filename="forum.xsl" fontsize="1.5em" /> </slide>
« previous php.pres (#1076) next »