PHP|Works talks.

This commit is contained in:
Ilia Alshanetsky
2004-10-13 14:53:59 +00:00
parent de98eb5ed5
commit bc1df0f093
184 changed files with 2225 additions and 0 deletions

76
php5_intro.xml Normal file
View File

@@ -0,0 +1,76 @@
<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>

80
php5xml.xml Normal file
View File

@@ -0,0 +1,80 @@
<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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

BIN
slides/php5_intro/che.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
slides/php5_intro/dolly.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

18
slides/php5_intro/dom.xml Normal file
View File

@@ -0,0 +1,18 @@
<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>

View File

@@ -0,0 +1,5 @@
<slide title="Creating XML w/DOM">
<example filename="obj_dom.php" result="1" fontsize="1.5em" />
</slide>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,20 @@
<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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,16 @@
<?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();
?>

View File

@@ -0,0 +1,13 @@
<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>

View File

@@ -0,0 +1,12 @@
<?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 */
?>

View File

@@ -0,0 +1,14 @@
<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>

View File

@@ -0,0 +1 @@
<?php class foo { public $bar; } ?>

View File

@@ -0,0 +1,14 @@
<?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
?>

View File

@@ -0,0 +1,11 @@
<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>

View File

@@ -0,0 +1,17 @@
<?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
?>

View File

@@ -0,0 +1,11 @@
<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>

View File

@@ -0,0 +1,15 @@
<?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
?>

View File

@@ -0,0 +1,18 @@
<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>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,6 @@
<?php
class foo {
var $bar;
function foo($val) { $this->bar = $val; }
}
?>

View File

@@ -0,0 +1,13 @@
<?php
class foo {
var $bar;
function __construct($val) {
$this->bar = $val;
}
function __destruct() {
unset($this->bar);
}
}
?>

View File

@@ -0,0 +1,7 @@
<?php
class foo {
const file_name = __FILE__;
}
echo foo::file_name; // will print current file name
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,13 @@
<?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)));
?>

View File

@@ -0,0 +1,15 @@
<?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
}
?>

View File

@@ -0,0 +1,12 @@
<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>

View File

@@ -0,0 +1,10 @@
<?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
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,18 @@
<?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
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,24 @@
<?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;
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,23 @@
<?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();
}
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,19 @@
<?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
?>

View File

@@ -0,0 +1,9 @@
<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>

View File

@@ -0,0 +1,20 @@
<?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;
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,18 @@
<?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
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,21 @@
<?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
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,17 @@
<?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
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,20 @@
<?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;
}
?>

View File

@@ -0,0 +1,12 @@
<?php
class foo {
static $bar = 123;
static function baz() {
return 456;
}
}
echo foo::$bar; // will print 123
echo foo::baz(); // will print 456
?>

View File

@@ -0,0 +1,12 @@
<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>

View File

@@ -0,0 +1,13 @@
<?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"
?>

View File

@@ -0,0 +1,9 @@
<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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,16 @@
<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>

View File

@@ -0,0 +1,12 @@
<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>

View File

@@ -0,0 +1,21 @@
<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>

View File

@@ -0,0 +1,5 @@
<?php
// instantiate SOAP client object
$client = new SoapObject("http://example.com/soap_server.php", "urn:Object");
echo $client->version(); // call version() method
?>

View File

@@ -0,0 +1,7 @@
<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>

View File

@@ -0,0 +1,10 @@
<?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
?>

View File

@@ -0,0 +1,11 @@
<?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
}
?>

View File

@@ -0,0 +1,5 @@
<slide title="Directory Iterator">
<example filename="spl_ex1.php" result="1" fontsize="1.5em" />z
</slide>

View File

@@ -0,0 +1,14 @@
<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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -0,0 +1,5 @@
<slide title="SQLite OO Interface">
<example filename="sqlite_oo.php" result="1" fontsize="1.5em" />
</slide>

View File

@@ -0,0 +1,5 @@
<slide title="SQLite Procedural Interface">
<example filename="sqlite_proc.php" result="1" fontsize="1.5em" />
</slide>

View File

@@ -0,0 +1,19 @@
<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>

View File

@@ -0,0 +1,17 @@
<?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>';
?>

View File

@@ -0,0 +1,19 @@
<?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>';
?>

View File

@@ -0,0 +1,16 @@
<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>

View File

@@ -0,0 +1,12 @@
<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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,9 @@
<?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
}
?>

View File

@@ -0,0 +1,18 @@
<?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);
?>

View File

@@ -0,0 +1,10 @@
<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>

View File

@@ -0,0 +1,5 @@
<slide title="Streams Example #2">
<example filename="streams2.php" result="0" fontsize="1.5em" />
</slide>

View File

@@ -0,0 +1,17 @@
<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>

View File

@@ -0,0 +1,18 @@
<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>

BIN
slides/php5_intro/tidy.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,8 @@
<?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));
?>

View File

@@ -0,0 +1,9 @@
<?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>

View File

@@ -0,0 +1,5 @@
<slide title="Correct HTML w/Tidy">
<example filename="tidy.php" result="1" fontsize="1.5em" />
</slide>

View File

@@ -0,0 +1,7 @@
<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>

View File

@@ -0,0 +1,18 @@
<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>

View File

@@ -0,0 +1,3 @@
<slide template="titlepage" fontsize="6em">
<title>Welcome!</title>
</slide>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,26 @@
<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>

39
slides/php5_intro/xsl.php Normal file
View File

@@ -0,0 +1,39 @@
<?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
?>

21
slides/php5_intro/xsl.xml Normal file
View File

@@ -0,0 +1,21 @@
<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>

View File

@@ -0,0 +1,5 @@
<slide title="XSL Transformation">
<example filename="xsl.php" result="1" fontsize="1.5em" />
</slide>

BIN
slides/php5xml/boxing.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
slides/php5xml/buzzword.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
slides/php5xml/choices.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
slides/php5xml/confused.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

18
slides/php5xml/dom.xml Normal file
View File

@@ -0,0 +1,18 @@
<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>

View File

@@ -0,0 +1,9 @@
<?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 />";
}
?>

View File

@@ -0,0 +1,5 @@
<slide title="Accessing Nodes w/DOM">
<example filename="dom_access.php" hide="0" result="1" type="php" fontsize="1.4em" />
</slide>

Some files were not shown because too many files have changed in this diff Show More