[git] presentations.git branch master updated. dd93a76

From: Date: Sun, 11 Mar 2012 21:52:30 +0000
Subject: [git] presentations.git branch master updated. dd93a76
Groups: php.pres 
Request: Send a blank email to pres+get-1783@lists.php.net to get a copy of this message
The branch master on presentations.git has been updated via dd93a7600d7ed07295f47714a716541ffaf1e2d9 (commit) from 8821f531f1d85da01eae8e3e04404f042b3cdccf (commit) http://git.php.net/?p=presentations.git;a=log;h=dd93a7600d7ed07295f47714a716541ffaf1e2d9;hp=8821f531f1d85da01eae8e3e04404f042b3cdccf Summary of changes: slides/intro/php54_misc.xml | 3 -- slides/intro/php54_object_func.xml | 18 ++++++++++++++++ slides/intro/php54_server.xml | 39 +++++++++++++++++++++++++++++++++++- slides/intro/php54_session.xml | 17 +++++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 slides/intro/php54_object_func.xml create mode 100644 slides/intro/php54_session.xml -- Log ---------------------------------------- commit dd93a7600d7ed07295f47714a716541ffaf1e2d9 Author: Rasmus Lerdorf <rasmus@php.net> Date: Sun Mar 11 14:42:15 2012 -0700 Tweaks diff --git a/slides/intro/php54_misc.xml b/slides/intro/php54_misc.xml index 8a976a3..e584aad 100644 --- a/slides/intro/php54_misc.xml +++ b/slides/intro/php54_misc.xml @@ -1,9 +1,6 @@ <slide title="Miscellaneous"> <break lines="2" /> -<blurb fontsize="4em">PHP 5.4: The new bits Davey Shafik Friday 12:00 - 13:00</blurb> - -<break lines="1"/> <blurb fontsize="4em">New Output API (internal code cleanup)</blurb> <break lines="1" /> diff --git a/slides/intro/php54_object_func.xml b/slides/intro/php54_object_func.xml new file mode 100644 index 0000000..52efe39 --- /dev/null +++ b/slides/intro/php54_object_func.xml @@ -0,0 +1,18 @@ +<slide title="Objects as Functions"> + +<blurb fontsize="4em">__invoke() magic method</blurb> +<example fontsize="2em" result='0' title=""><![CDATA[<?php +class Money { + private $value; + function __construct($val) { + $this->value = $val; + } + function __invoke() { + return sprintf('$%.2f',$this->value); + } +} +$Money = new Money(11.02/5*13); +echo $Money(); // $28.65 +?>]]></example> + +</slide> diff --git a/slides/intro/php54_server.xml b/slides/intro/php54_server.xml index e08ffa1..eb42a58 100644 --- a/slides/intro/php54_server.xml +++ b/slides/intro/php54_server.xml @@ -4,7 +4,44 @@ <blurb fontsize="4em">Built-in Web server for testing</blurb> <example fontsize="2em" result='0' title="" type="shell"><![CDATA[ % php -S localhost:8000 -Server is listening on localhost:8000... Press CTRL-C to quit. +PHP 5.4.0 Development Server started at Sun Mar 11 13:27:09 2012 +Listening on localhost:8080 +Document root is /home/rasmus +Press Ctrl-C to quit. ]]></example> +<break lines="1" /> +<blurb fontsize="4em">The DocumentRoot is the current dir by default, but you can specify a different one.</blurb> +<example fontsize="2em" result='0' title="" type="shell"><![CDATA[ +% php -S localhost:8080 -t /tmp/web +PHP 5.4.0 Development Server started at Sun Mar 11 13:28:01 2012 +Listening on localhost:8080 +Document root is /tmp/web +Press Ctrl-C to quit. +[Sun Mar 11 13:31:04 2012] 127.0.0.1:49393 [200]: / +[Sun Mar 11 13:31:04 2012] 127.0.0.1:49394 [200]: /php.png +[Sun Mar 11 13:31:04 2012] 127.0.0.1:49395 [404]: /favicon.ico - No such file or directory +]]></example> + +<break lines="1" /> +<blurb fontsize="4em">Many frameworks also have a default global router script. You can easily wrap it and call it like this:</blurb> +<example fontsize="2em" result='0' title="" type="shell"><![CDATA[ +% php -S localhost:8080 /path/to/router.php +PHP 5.4.0 Development Server started at Sun Mar 11 13:28:01 2012 +Listening on localhost:8080 +Document root is /tmp/web +Press Ctrl-C to quit. +]]></example> + +<blurb fontsize="4em">And the wrapper might be as simple as:</blurb> +<example fontsize="2em" result='0' title=""><![CDATA[<?php +if (preg_match('!\.php$!', $_SERVER["REQUEST_URI"])) { + require basename($_SERVER["REQUEST_URI"]); +} else if (strpos($_SERVER["REQUEST_URI"], '.')) { + return false; // serve the requested file as-is. +} else { + Framework::Router($_SERVER["REQUEST_URI"]); +} +?>]]></example> + </slide> diff --git a/slides/intro/php54_session.xml b/slides/intro/php54_session.xml new file mode 100644 index 0000000..5c77740 --- /dev/null +++ b/slides/intro/php54_session.xml @@ -0,0 +1,17 @@ +<slide title="Session Object"> + +<blurb fontsize="4em">Native Session Handler Interface</blurb> +<example fontsize="2em" result='0' title=""><![CDATA[<?php +SessionHandler implements SessionHandlerInterface { + /* Methods */ + public int close ( void ) + public int destroy ( string $sessionid ) + public int gc ( int $maxlifetime ) + public int open ( string $save_path , string $sessionid ) + public string read ( string $sessionid ) + public int write ( string $sessionid , string $sessiondata ) +} +session_set_save_handler(new MySessionHandler); +?>]]></example> + +</slide> Thank you for your contribution.

« previous php.pres (#1783) next »