cvs: presentations /slides/intro oop5.xml xml_eg.xml

From: Date: Wed, 19 Oct 2005 15:49:24 +0000
Subject: cvs: presentations /slides/intro oop5.xml xml_eg.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1210@lists.php.net to get a copy of this message
rasmus Wed Oct 19 11:49:24 2005 EDT Added files: /presentations/slides/intro oop5.xml xml_eg.xml Log: More missing slides http://cvs.php.net/co.php/presentations/slides/intro/oop5.xml?r=1.1&p=1 Index: presentations/slides/intro/oop5.xml +++ presentations/slides/intro/oop5.xml <slide title="OOP"> <break lines="1" /> <example title="Objects Are References" result="0"><![CDATA[<?php $a = new my_class; $b = $a; $c = clone $a; ?>]]></example> <example title="New constructor/destructor naming" result="0"><![CDATA[<?php class my_class { function __construct() { echo "Constructor"; } function __destruct() { echo "Destructor"; } } ?>]]></example> <example title="PPP" result="0"><![CDATA[<?php class my_class { public $a; protected $b; private $c; } ?>]]></example> <example title="Overloaded Properties and Methods" result="0"><![CDATA[<?php class my_class { function __set($name, $value) { } function __get($name) { } function __call($name, $args) { } } ?>]]></example> <example title="Object type hinting"><![CDATA[<?php class the_class { public $var = 'foo'; } class my_other_class { public function __construct(the_class $obj) { echo $obj->var; } } $a = new the_class; $b = new my_other_class($a); $c = new my_other_class($b); ?>]]></example> <example hide="1" result="1"><![CDATA[foo<br /> Fatal error: Argument 1 must be an instance of the_class in script.php on line 6]]></example> <example title="Interfaces" result="1"><![CDATA[<?php interface abc { public function setVariable($name, $var); public function getVariable($name); } class my_abc implements abc { private $vars = array(); public function setVariable($name, $var) { $this->vars[$name] = $var; } public function getVariable($name) { return $this->vars[$name]; } } $test = new my_abc; $test->setVariable('foo','bar'); echo $test->getVariable('foo'); ?>]]></example> <example title="Bad Interface" result="0"><![CDATA[<?php class my_other_class implements abc { public function setVariable($name, $var) { $this->vars[$name] = $var; } } ?>]]></example> <example hide="1" result="1">Fatal error: Class my_other_class contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (abc::getVariable) script.php on line 2</example> <example title="final"><![CDATA[<?php class my_main_class { public function foo() { } final public function bar() { } } class my_other_class extends my_main_class { public function foo() { } public function bar() { } } ?>]]></example> <example hide="1" result="1">Fatal error: Cannot override final method my_main_class::bar() in script.php on line 9</example> <example title="Base.inc"><![CDATA[<?php abstract class Base { public function __toString() { return '<pre>'.print_r($this,TRUE).'</pre>'; } } ?>]]></example> <example title="Autoload" result="1"><![CDATA[<?php function __autoload($class) { echo "autoload called for $class\n"; require "presentations/slides/keynotes/$class.inc"; } class my_class2 extends Base { function __construct($arg) { $this->prop = $arg; } } $test = new my_class2('foo'); echo $test; ?>]]></example> <example title="Exceptions" result="0"><![CDATA[<?php try { mysql_connect('localhost'); mysql_select_db('game'); $r = mysql_query('SELECT * FROM news'); } catch (Exception $e) { /* Do recovery */ exit(); } ?>]]></example> <blurb fontsize="5em">And more... Reflection, Iteration, Comparison.</blurb> <blurb fontsize="5em">Go read http://php.net/oop5</blurb> </slide> http://cvs.php.net/co.php/presentations/slides/intro/xml_eg.xml?r=1.1&p=1 Index: presentations/slides/intro/xml_eg.xml +++ presentations/slides/intro/xml_eg.xml <slide title="XML"> <break lines="1" /> <php><![CDATA[<?php chdir('presentations/slides/intro');?>]]></php> <example title="All XML handling based on libxml2" marginleft="2em" marginright="0em" result="0"><![CDATA[<?php $dom = new domDocument; $dom->load('menu.xml'); ?>]]></example> <example title="menu.xml" result="1" hide="1" marginleft="2em" marginright="0em" fontsize="1.75em" rfontsize="1.5em"><![CDATA[<?php class entities_filter extends php_user_filter { function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = htmlentities($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } } stream_filter_register("entities", "entities_filter"); echo "<pre>"; readfile("php://filter/read=entities/resource=menu.xml"); echo "</pre>"; ?>]]></example> <example title="XPath" result="1" fontsize="1.5em" marginleft="2em" marginright="0em"><![CDATA[<?php $dom = domdocument::load('menu.xml'); $ctx = new domXPath($dom); $result = $ctx->query('/breakfast_menu/food[@itemno > 3]/price/text()'); foreach($result as $node) { echo $node->nodeValue."<br />\n"; } ?>]]></example> <example title="XSL" result="1" marginleft="2em" marginright="0em"><![CDATA[<?php $dom = domdocument::load('menu.xml'); $domxsl = domDocument::load('menu.xsl'); $proc = new xsltProcessor; $proc->importStyleSheet($domxsl); echo $proc->transformToXML($dom); ?>]]></example> <example title="SimpleXML" result="1" marginleft="2em"><![CDATA[<?php $menu = simplexml_load_file('menu.xml'); foreach ($menu->food as $item) { echo $item['itemno'] . ") "; echo $item->price . " ... "; echo $item->name . "<br />\n"; } ?>]]></example> </slide>

« previous php.pres (#1210) next »