com presentations: Re-gen reveal.js presentations: phpdaymx13.html slides/intro/nold.xml sunshinephp14.html
| From: | Rasmus Lerdorf | Date: | Tue, 11 Mar 2014 22:21:15 +0000 |
| Subject: | com presentations: Re-gen reveal.js presentations: phpdaymx13.html slides/intro/nold.xml sunshinephp14.html | ||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1955@lists.php.net to get a copy of this message | ||
Commit: 8c6ea8b8dc0b59d7d037ca546588995be615d5c7
Author: Rasmus Lerdorf <rasmus@php.net> Tue, 11 Mar 2014 15:21:15 -0700
Parents: 928bc719e4527ab0405b4f8277b3acca0f4437b9
Branches: master
Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=8c6ea8b8dc0b59d7d037ca546588995be615d5c7
Log:
Re-gen reveal.js presentations
Changed paths:
M phpdaymx13.html
M slides/intro/nold.xml
M sunshinephp14.html
diff --git a/phpdaymx13.html b/phpdaymx13.html index 0df0df2..a202fb2 100644 --- a/phpdaymx13.html +++ b/phpdaymx13.html @@ -18,7 +18,7 @@ <link rel="stylesheet" href="/samdark.css" id="theme"> <!-- For syntax highlighting --> - <link rel="stylesheet" href="/github.css"> + <link rel="stylesheet" href="/styles/github.css"> <!-- If the query includes 'print-pdf', include the PDF print sheet --> <script> @@ -54,13 +54,13 @@ </section> <section> <h2 margin-bottom="2em">1993</h2><br> - <pre><code data-trim class="php">#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> + <pre><code>#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> -#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && - (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) +#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && \ + (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) int htoi(char *s) { int value; @@ -68,11 +68,11 @@ int htoi(char *s) { c = s[0]; if(isupper(c)) c = tolower(c); - value=(c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; + value=(c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; c = s[1]; if(isupper(c)) c = tolower(c); - value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; + value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; return(value); } @@ -81,21 +81,21 @@ void main(int argc, char *argv[]) { char *params, *data, *dest, *s, *tmp; char *name, *age; - puts("Content-type: text/html\r\n"); - puts("<HTML><HEAD><TITLE>Form Example</TITLE></HEAD>"); - puts("<BODY><H1>My Example Form</H1>"); - puts("<FORM action=\"form.cgi\" method=\"GET\">"); - puts("Name: <INPUT type=\"text\" name=\"name\">"); - puts("Age: <INPUT type=\"text\" name=\"age\">"); - puts("<BR><INPUT type=\"submit\">"); - puts("</FORM>"); - - data = getenv("QUERY_STRING"); - if(data && *data) { + puts("Content-type: text/html\r\n"); + puts("<HTML><HEAD><TITLE>Form Example</TITLE></HEAD>"); + puts("<BODY><H1>My Example Form</H1>"); + puts("<FORM action=\"form.cgi\" method=\"GET\">"); + puts("Name: <INPUT type=\"text\" name=\"name\">"); + puts("Age: <INPUT type=\"text\" name=\"age\">"); + puts("<BR><INPUT type=\"submit\">"); + puts("</FORM>"); + + data = getenv("QUERY_STRING"); + if(data && *data) { params = data; dest = data; while(*data) { if(*data=='+') *dest=' '; - else if(*data == '%' && ishex(*(data+1))&&ishex(*(data+2))) { + else if(*data == '%' && ishex(*(data+1))&&ishex(*(data+2))) { *dest = (char) htoi(data + 1); data+=2; } else *dest = *data; @@ -103,55 +103,55 @@ void main(int argc, char *argv[]) { dest++; } *dest = '\0'; - s = strtok(params,"&"); + s = strtok(params,"&"); do { tmp = strchr(s,'='); if(tmp) { *tmp = '\0'; - if(!strcmp(s,"name")) name = tmp+1; - else if(!strcmp(s,"age")) age = tmp+1; + if(!strcmp(s,"name")) name = tmp+1; + else if(!strcmp(s,"age")) age = tmp+1; } - } while(s=strtok(NULL,"&")); + } while(s=strtok(NULL,"&")); - printf("Hi %s, you are %s years old\n",name,age); + printf("Hi %s, you are %s years old\n",name,age); } - puts("</BODY></HTML>"); + puts("</BODY></HTML>"); } </code></pre> </section> <section> <h2 margin-bottom="2em">1993</h2><br> - <pre><code data-trim class="php">use CGI qw(:standard); + <pre><code>use CGI qw(:standard); print header; print start_html('Form Example'), h1('My Example Form'), start_form, - "Name: ", textfield('name'), + "Name: ", textfield('name'), p, - "Age: ", textfield('age'), + "Age: ", textfield('age'), p, submit, end_form; if(param()) { - print "Hi ",em(param('name')), - "You are ",em(param('age')), - " years old"; + print "Hi ",em(param('name')), + "You are ",em(param('age')), + " years old"; } print end_html;</code></pre> </section> <section> <h2 margin-bottom="2em">1994</h2><br> - <pre><code data-trim class="php"><html><head><title>Form Example</title></head> -<body><h1>My Example Form</h1> -<form action="form.phtml" method="POST"> -Name: <input type="text" name="name"> -Age: <input type="text" name="age"> -<br><input type="submit"> -</form> -<?if($name):?> -Hi <?echo $name?>, you are <?echo $age?> years old -<?endif?> -</body></html></code></pre> + <pre><code><html><head><title>Form Example</title></head> +<body><h1>My Example Form</h1> +<form action="form.phtml" method="POST"> +Name: <input type="text" name="name"> +Age: <input type="text" name="age"> +<br><input type="submit"> +</form> +<?if($name):?> +Hi <?echo $name?>, you are <?echo $age?> years old +<?endif?> +</body></html></code></pre> </section> <section> <h3 class="p">Focus on the Ecosystem</h3> @@ -178,14 +178,12 @@ Hi <?echo $name?>, you are <?echo $age?> years old <li>magic_quotes?</li> </ul> <h3 class="p">OMGWTFBBQ?</h3> - <pre><code data-trim class="php"> -array_search($needle, $haystack); + <pre><code>array_search($needle, $haystack); strstr($haystack, $needle); in_array($needle, $haystack); substr_count($haystack, $needle); array_key_exists($needle, $haystack); -strchr($haystack, $needle); -</code></pre> +strchr($haystack, $needle);</code></pre> </section> <section> <h3 class="p">Performance</h3> @@ -230,32 +228,28 @@ strchr($haystack, $needle); <h4 class="p">✔ Traits aka Horizontal Code Reuse</h4> <p class="p"> (Compiler-assisted Copy-and-Paste)</p> <h4 class="p">✔ Short Array Syntax</h4> - <pre><code data-trim class="php"> -$a = [1, 2, 3]; -$b = ['foo' => 'orange', 'bar' => 'apple']; -</code></pre> + <pre><code>$a = [1, 2, 3]; +$b = ['foo' => 'orange', 'bar' => 'apple'];</code></pre> </section> <section id="php54page3"> <h4 class="p">✔ Function Array Dereferencing</h4> - <pre><code data-trim class="php"> -function fruits() { + <pre><code>function fruits() { return array('apple', 'banana', 'orange'); } echo fruits()[0]; // Outputs: apple -?></code></pre> +?></code></pre> <h4 class="p">✔ $this from current scope supported in Closures</h4> - <pre><code data-trim class="php"> -class Foo { - private $prop = "bar"; + <pre><code>class Foo { + private $prop = "bar"; public function getPrinter() { - return function() { echo ucfirst($this->prop); }; + return function() { echo ucfirst($this->prop); }; } } $a = new Foo; -$func = $a->getPrinter(); +$func = $a->getPrinter(); $func(); // Outputs: Bar -?></code></pre> +?></code></pre> </section> <section id="php54page4"> <h4 class="p">✔ <?= is now always available</h4> @@ -267,22 +261,19 @@ $func(); // Outputs: Bar <ul> <li>JsonSerializable</li> </ul> - <pre><code data-trim class="php"> -class Foo implements JsonSerializable { + <pre><code>class Foo implements JsonSerializable { private $data = 'Bar'; public function jsonSerialize() { - return array('data'=>$this->data); + return array('data'=>$this->data); } } -echo json_encode(new Foo); // Outputs: {"data":"Bar"}</code></pre> +echo json_encode(new Foo); // Outputs: {"data":"Bar"}</code></pre> </section> <section id="php54page5"> <h4 class="p">✔ mysqlnd used by default everywhere</h4> <h4 class="p">✔ iterator support added to mysqli (mysqli_result implements Traversable)</h4> <h4 class="p">✔ Binary notation</h4> - <pre><code data-trim class="php"> -$mask = 0b010101; -</code></pre> + <pre><code>$mask = 0b010101;</code></pre> <h4 class="p">✔ AES Support added to OpenSSL</h4> <h4 class="p">✔ Tokyo Cabinet and DB5 support added to dba</h4> <h4 class="p">✔ Added stack frame count arg to debug_backtrace()</h4> @@ -314,26 +305,22 @@ PHP 5.4 + Opcache vs. PHP 5.3 + APC <section id="php54trip1"> <h2 margin-bottom="2em">Watch out for...</h2><br> <p class="p">✔ default charset is UTF-8 instead of ISO-8859-1</p> - <pre><code data-trim class="php"> -echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.3 "abc�def" -echo htmlspecialchars("abc".chr(0xE0)."def", NULL, 'UTF-8'); // 5.3 "" -echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.4 "" -echo htmlspecialchars("abc".chr(0xE0)."def", ENT_IGNORE); // 5.4 "abcdef"</code></pre> + <pre><code>echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.3 "abc�def" +echo htmlspecialchars("abc".chr(0xE0)."def", NULL, 'UTF-8'); // 5.3 "" +echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.4 "" +echo htmlspecialchars("abc".chr(0xE0)."def", ENT_IGNORE); // 5.4 "abcdef"</code></pre> <p class="p">✔ array to string conversion notice</p> - <pre><code data-trim class="php"> -echo [1,2,3]; + <pre><code>echo [1,2,3]; // Notice: Array to string conversion in test.php code on line 1 array_diff([1,2,3], [1,2, [3] ]); -// Notice: Array to string conversion in test.php on line 2 -</code></pre> +// Notice: Array to string conversion in test.php on line 2</code></pre> <p class="p">✔ register_globals completely removed</p> <p class="p">✔ magic quotes completely removed</p> </section> <section id="php54trip2"> <p class="p">✔ removed variable break/continue</p> - <pre><code data-trim class="php"> -$var = 'label'; + <pre><code>$var = 'label'; while(1) { break $var; continue $var; @@ -344,16 +331,14 @@ label:</code></pre> </section> <section id="php54trip3"> <p class="p">✔ extending an abstract constructor must match the signature</p> - <pre><code data-trim class="php"> - abstract class Base { + <pre><code>abstract class Base { abstract public function __construct(); } class Foo extends Base { public function __construct($bar) {} // FATAL Declaration of Foo::__construct() must be compatible // with Base::__construct() - } -</code></pre> + }</code></pre> <p class="p">✔ stream_select() preserves keys of array arg</p> <p class="p">✔ XSLT writes are disabled by default</p> <p class="p">✔ mcrypt_generic_end() removed in favour of mcrypt_generic_deinit()</p> @@ -374,20 +359,18 @@ label:</code></pre> </section> <section id="generators"> <h4 class="p">✔ Generators</h4> - <pre><code data-trim class="php"> -function xrange($start, $end) { - for ($i = $start; $i <= $end; $i ++) { + <pre><code>function xrange($start, $end) { + for ($i = $start; $i <= $end; $i ++) { yield $i; } } foreach (xrange(0, 5) as $i) { - echo $i, "\n"; + echo $i, "\n"; }</code></pre> </section> <section id="finally"> <h4 class="p">✔ finally</h4> - <pre><code data-trim class="php"> -$db = mysqli_connect(); + <pre><code>$db = mysqli_connect(); try { call_some_function($db); } finally { @@ -396,96 +379,85 @@ try { </section> <section id="foreachlist"> <h4 class="p">✔ list() in foreach</h4> - <pre><code data-trim class="php"> -$names = [ ['John','Smith'], ['Fred','Johnson'] ]; + <pre><code>$names = [ ['John','Smith'], ['Fred','Johnson'] ]; foreach($names as list($first,$last)) { echo $first,$last; }</code></pre> </section> <section id="constarray"> <h4 class="p">✔ Const array/string Dereferencing</h4> - <pre><code data-trim class="php"> -echo array(1, 2, 3)[0]; //output 1 -echo "foobar"[3]; //output b + <pre><code>echo array(1, 2, 3)[0]; //output 1 +echo "foobar"[3]; //output b echo [1,3,4][2]; //output 4</code></pre> </section> <section id="others"> <h4 class="p">✔ empty() support for functions/expressions</h4> <h4 class="p">✔ curl upload functionality rewritten</h4> <h4 class="p">✔ Simplified password hashing API</h4> - <pre><code data-trim class="php"> -// Hash -$hash = password_hash("super secret",PASSWORD_BCRYPT); + <pre><code>// Hash +$hash = password_hash("super secret",PASSWORD_BCRYPT); // To validate $pwd against the stored hash if (password_verify($pwd, $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; -} -</code></pre> +}</code></pre> </section> </section> <section> <section id="php56"> <h2 margin-bottom="2em">PHP 5.6</h2><br> <h4 class="p">✔ Variadic functions</h4> - <pre><code data-trim class="php"> -class MySQL implements DB { + <pre><code>class MySQL implements DB { public function query($query, ...$params) { - $stmt = $this->pdo->prepare($query); - $stmt->execute($params); + $stmt = $this->pdo->prepare($query); + $stmt->execute($params); return $stmt; } } $q = 'SELECT * FROM users WHERE id = ?'; -$user = $db->query($q, $userID)->fetch();</code></pre> +$user = $db->query($q, $userID)->fetch();</code></pre> </section> <section id="php56unpack"> <h4 class="p">✔ Argument Unpacking</h4> - <pre><code data-trim class="php"> -// A better call_user_func_args + <pre><code>// A better call_user_func_args $args1 = [1, 2, 3]; $args2 = [4, 5, 6]; test(...$args1, ...$args2); // [1, 2, 3, 4, 5, 6] test(1, 2, 3, ...$args2); // [1, 2, 3, 4, 5, 6] test(...$args1, 4, 5, 6); // [1, 2, 3, 4, 5, 6]</code></pre> <h4 class="p">✔ Constant scalar expressions</h4> - <pre><code data-trim class="php"> -class Foo { + <pre><code>class Foo { const FOO = 1 + 1; - const BAR = 1 << 1; - const GREETING = "HELLO"; - const BAZ = self::GREETING." WORLD!" + const BAR = 1 << 1; + const GREETING = "HELLO"; + const BAZ = self::GREETING." WORLD!" }</code></pre> </section> <section id="php56pow"> <h4 class="p">✔ Add right-associative power operator **</h4> - <pre><code data-trim class="php"> -echo 2 ** 3 ** 2; // 512 (not 64) + <pre><code>echo 2 ** 3 ** 2; // 512 (not 64) echo -3 ** 2; // -9 (not 9) echo 1 - 3 ** 2; // -8 echo ~3 ** 2; // -10 (not 16)</code></pre> <h4 class="p">✔ Internal operator overloading for internal features like GMP</h4> - <pre><code data-trim class="php"> -echo 2**512; -echo "\n"; + <pre><code>echo 2**512; +echo "\n"; $n = gmp_init(2); -echo $n**512; -</code></pre> - <pre><code data-trim class="php">1.3407807929943E+154 +echo $n**512;</code></pre> + <pre><code>1.3407807929943E+154 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096 </code></pre> </section> <section id="php56use"> <h4 class="p">✔ use function and use const namespace imports</h4> - <pre><code data-trim class="php"> -include 'template.inc'; + <pre><code>include 'template.inc'; include 'db.inc'; use function template\header, template\footer, db\query; header('My Page'); query('select * from stuff'); -footer(); </code></pre> +footer();</code></pre> <h4 class="p">✔ SSL Peer verification by default</h4> <h4 class="p">✔ New phpdbg SAPI</h4> <h4 class="p">✔ Support for > 2GB file uploads</h4> @@ -572,7 +544,7 @@ footer(); </code></pre> // Optional libraries used to extend on reveal.js dependencies: [ { src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, - { src: '/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, + { src: '/highlight.pack.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '/reveal.js/plugin/zoom-js/zoom.js', async: true, callback: function() { return !!document.body.classList; } }, { src: '/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } } ] diff --git a/slides/intro/nold.xml b/slides/intro/nold.xml index 12edf12..8615e03 100644 --- a/slides/intro/nold.xml +++ b/slides/intro/nold.xml @@ -4,7 +4,7 @@ #include <ctype.h> #include <string.h> -#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && +#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && \ (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) int htoi(char *s) { diff --git a/sunshinephp14.html b/sunshinephp14.html index 407a326..0a1387c 100644 --- a/sunshinephp14.html +++ b/sunshinephp14.html @@ -18,7 +18,7 @@ <link rel="stylesheet" href="/samdark.css" id="theme"> <!-- For syntax highlighting --> - <link rel="stylesheet" href="/github.css"> + <link rel="stylesheet" href="/styles/github.css"> <!-- If the query includes 'print-pdf', include the PDF print sheet --> <script> @@ -67,20 +67,18 @@ </section> <section id="generators"> <h4 class="p">✔ Generators</h4> - <pre><code data-trim class="php"> -function xrange($start, $end) { - for ($i = $start; $i <= $end; $i ++) { + <pre><code>function xrange($start, $end) { + for ($i = $start; $i <= $end; $i ++) { yield $i; } } foreach (xrange(0, 5) as $i) { - echo $i, "\n"; + echo $i, "\n"; }</code></pre> </section> <section id="finally"> <h4 class="p">✔ finally</h4> - <pre><code data-trim class="php"> -$db = mysqli_connect(); + <pre><code>$db = mysqli_connect(); try { call_some_function($db); } finally { @@ -89,96 +87,85 @@ try { </section> <section id="foreachlist"> <h4 class="p">✔ list() in foreach</h4> - <pre><code data-trim class="php"> -$names = [ ['John','Smith'], ['Fred','Johnson'] ]; + <pre><code>$names = [ ['John','Smith'], ['Fred','Johnson'] ]; foreach($names as list($first,$last)) { echo $first,$last; }</code></pre> </section> <section id="constarray"> <h4 class="p">✔ Const array/string Dereferencing</h4> - <pre><code data-trim class="php"> -echo array(1, 2, 3)[0]; //output 1 -echo "foobar"[3]; //output b + <pre><code>echo array(1, 2, 3)[0]; //output 1 +echo "foobar"[3]; //output b echo [1,3,4][2]; //output 4</code></pre> </section> <section id="others"> <h4 class="p">✔ empty() support for functions/expressions</h4> <h4 class="p">✔ curl upload functionality rewritten</h4> <h4 class="p">✔ Simplified password hashing API</h4> - <pre><code data-trim class="php"> -// Hash -$hash = password_hash("super secret",PASSWORD_BCRYPT); + <pre><code>// Hash +$hash = password_hash("super secret",PASSWORD_BCRYPT); // To validate $pwd against the stored hash if (password_verify($pwd, $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; -} -</code></pre> +}</code></pre> </section> </section> <section> <section id="php56"> <h2 margin-bottom="2em">PHP 5.6</h2><br> <h4 class="p">✔ Variadic functions</h4> - <pre><code data-trim class="php"> -class MySQL implements DB { + <pre><code>class MySQL implements DB { public function query($query, ...$params) { - $stmt = $this->pdo->prepare($query); - $stmt->execute($params); + $stmt = $this->pdo->prepare($query); + $stmt->execute($params); return $stmt; } } $q = 'SELECT * FROM users WHERE id = ?'; -$user = $db->query($q, $userID)->fetch();</code></pre> +$user = $db->query($q, $userID)->fetch();</code></pre> </section> <section id="php56unpack"> <h4 class="p">✔ Argument Unpacking</h4> - <pre><code data-trim class="php"> -// A better call_user_func_args + <pre><code>// A better call_user_func_args $args1 = [1, 2, 3]; $args2 = [4, 5, 6]; test(...$args1, ...$args2); // [1, 2, 3, 4, 5, 6] test(1, 2, 3, ...$args2); // [1, 2, 3, 4, 5, 6] test(...$args1, 4, 5, 6); // [1, 2, 3, 4, 5, 6]</code></pre> <h4 class="p">✔ Constant scalar expressions</h4> - <pre><code data-trim class="php"> -class Foo { + <pre><code>class Foo { const FOO = 1 + 1; - const BAR = 1 << 1; - const GREETING = "HELLO"; - const BAZ = self::GREETING." WORLD!" + const BAR = 1 << 1; + const GREETING = "HELLO"; + const BAZ = self::GREETING." WORLD!" }</code></pre> </section> <section id="php56pow"> <h4 class="p">✔ Add right-associative power operator **</h4> - <pre><code data-trim class="php"> -echo 2 ** 3 ** 2; // 512 (not 64) + <pre><code>echo 2 ** 3 ** 2; // 512 (not 64) echo -3 ** 2; // -9 (not 9) echo 1 - 3 ** 2; // -8 echo ~3 ** 2; // -10 (not 16)</code></pre> <h4 class="p">✔ Internal operator overloading for internal features like GMP</h4> - <pre><code data-trim class="php"> -echo 2**512; -echo "\n"; + <pre><code>echo 2**512; +echo "\n"; $n = gmp_init(2); -echo $n**512; -</code></pre> - <pre><code data-trim class="php">1.3407807929943E+154 +echo $n**512;</code></pre> + <pre><code>1.3407807929943E+154 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096 </code></pre> </section> <section id="php56use"> <h4 class="p">✔ use function and use const namespace imports</h4> - <pre><code data-trim class="php"> -include 'template.inc'; + <pre><code>include 'template.inc'; include 'db.inc'; use function template\header, template\footer, db\query; header('My Page'); query('select * from stuff'); -footer(); </code></pre> +footer();</code></pre> <h4 class="p">✔ SSL Peer verification by default</h4> <h4 class="p">✔ New phpdbg SAPI</h4> <h4 class="p">✔ Support for > 2GB file uploads</h4> @@ -283,7 +270,7 @@ footer(); </code></pre> // Optional libraries used to extend on reveal.js dependencies: [ { src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, - { src: '/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, + { src: '/highlight.pack.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '/reveal.js/plugin/zoom-js/zoom.js', async: true, callback: function() { return !!document.body.classList; } }, { src: '/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } } ]
diff --git a/phpdaymx13.html b/phpdaymx13.html index 0df0df2..a202fb2 100644 --- a/phpdaymx13.html +++ b/phpdaymx13.html @@ -18,7 +18,7 @@ <link rel="stylesheet" href="/samdark.css" id="theme"> <!-- For syntax highlighting --> - <link rel="stylesheet" href="/github.css"> + <link rel="stylesheet" href="/styles/github.css"> <!-- If the query includes 'print-pdf', include the PDF print sheet --> <script> @@ -54,13 +54,13 @@ </section> <section> <h2 margin-bottom="2em">1993</h2><br> - <pre><code data-trim class="php">#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> + <pre><code>#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> -#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && - (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) +#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && \ + (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) int htoi(char *s) { int value; @@ -68,11 +68,11 @@ int htoi(char *s) { c = s[0]; if(isupper(c)) c = tolower(c); - value=(c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; + value=(c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; c = s[1]; if(isupper(c)) c = tolower(c); - value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; + value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; return(value); } @@ -81,21 +81,21 @@ void main(int argc, char *argv[]) { char *params, *data, *dest, *s, *tmp; char *name, *age; - puts("Content-type: text/html\r\n"); - puts("<HTML><HEAD><TITLE>Form Example</TITLE></HEAD>"); - puts("<BODY><H1>My Example Form</H1>"); - puts("<FORM action=\"form.cgi\" method=\"GET\">"); - puts("Name: <INPUT type=\"text\" name=\"name\">"); - puts("Age: <INPUT type=\"text\" name=\"age\">"); - puts("<BR><INPUT type=\"submit\">"); - puts("</FORM>"); - - data = getenv("QUERY_STRING"); - if(data && *data) { + puts("Content-type: text/html\r\n"); + puts("<HTML><HEAD><TITLE>Form Example</TITLE></HEAD>"); + puts("<BODY><H1>My Example Form</H1>"); + puts("<FORM action=\"form.cgi\" method=\"GET\">"); + puts("Name: <INPUT type=\"text\" name=\"name\">"); + puts("Age: <INPUT type=\"text\" name=\"age\">"); + puts("<BR><INPUT type=\"submit\">"); + puts("</FORM>"); + + data = getenv("QUERY_STRING"); + if(data && *data) { params = data; dest = data; while(*data) { if(*data=='+') *dest=' '; - else if(*data == '%' && ishex(*(data+1))&&ishex(*(data+2))) { + else if(*data == '%' && ishex(*(data+1))&&ishex(*(data+2))) { *dest = (char) htoi(data + 1); data+=2; } else *dest = *data; @@ -103,55 +103,55 @@ void main(int argc, char *argv[]) { dest++; } *dest = '\0'; - s = strtok(params,"&"); + s = strtok(params,"&"); do { tmp = strchr(s,'='); if(tmp) { *tmp = '\0'; - if(!strcmp(s,"name")) name = tmp+1; - else if(!strcmp(s,"age")) age = tmp+1; + if(!strcmp(s,"name")) name = tmp+1; + else if(!strcmp(s,"age")) age = tmp+1; } - } while(s=strtok(NULL,"&")); + } while(s=strtok(NULL,"&")); - printf("Hi %s, you are %s years old\n",name,age); + printf("Hi %s, you are %s years old\n",name,age); } - puts("</BODY></HTML>"); + puts("</BODY></HTML>"); } </code></pre> </section> <section> <h2 margin-bottom="2em">1993</h2><br> - <pre><code data-trim class="php">use CGI qw(:standard); + <pre><code>use CGI qw(:standard); print header; print start_html('Form Example'), h1('My Example Form'), start_form, - "Name: ", textfield('name'), + "Name: ", textfield('name'), p, - "Age: ", textfield('age'), + "Age: ", textfield('age'), p, submit, end_form; if(param()) { - print "Hi ",em(param('name')), - "You are ",em(param('age')), - " years old"; + print "Hi ",em(param('name')), + "You are ",em(param('age')), + " years old"; } print end_html;</code></pre> </section> <section> <h2 margin-bottom="2em">1994</h2><br> - <pre><code data-trim class="php"><html><head><title>Form Example</title></head> -<body><h1>My Example Form</h1> -<form action="form.phtml" method="POST"> -Name: <input type="text" name="name"> -Age: <input type="text" name="age"> -<br><input type="submit"> -</form> -<?if($name):?> -Hi <?echo $name?>, you are <?echo $age?> years old -<?endif?> -</body></html></code></pre> + <pre><code><html><head><title>Form Example</title></head> +<body><h1>My Example Form</h1> +<form action="form.phtml" method="POST"> +Name: <input type="text" name="name"> +Age: <input type="text" name="age"> +<br><input type="submit"> +</form> +<?if($name):?> +Hi <?echo $name?>, you are <?echo $age?> years old +<?endif?> +</body></html></code></pre> </section> <section> <h3 class="p">Focus on the Ecosystem</h3> @@ -178,14 +178,12 @@ Hi <?echo $name?>, you are <?echo $age?> years old <li>magic_quotes?</li> </ul> <h3 class="p">OMGWTFBBQ?</h3> - <pre><code data-trim class="php"> -array_search($needle, $haystack); + <pre><code>array_search($needle, $haystack); strstr($haystack, $needle); in_array($needle, $haystack); substr_count($haystack, $needle); array_key_exists($needle, $haystack); -strchr($haystack, $needle); -</code></pre> +strchr($haystack, $needle);</code></pre> </section> <section> <h3 class="p">Performance</h3> @@ -230,32 +228,28 @@ strchr($haystack, $needle); <h4 class="p">✔ Traits aka Horizontal Code Reuse</h4> <p class="p"> (Compiler-assisted Copy-and-Paste)</p> <h4 class="p">✔ Short Array Syntax</h4> - <pre><code data-trim class="php"> -$a = [1, 2, 3]; -$b = ['foo' => 'orange', 'bar' => 'apple']; -</code></pre> + <pre><code>$a = [1, 2, 3]; +$b = ['foo' => 'orange', 'bar' => 'apple'];</code></pre> </section> <section id="php54page3"> <h4 class="p">✔ Function Array Dereferencing</h4> - <pre><code data-trim class="php"> -function fruits() { + <pre><code>function fruits() { return array('apple', 'banana', 'orange'); } echo fruits()[0]; // Outputs: apple -?></code></pre> +?></code></pre> <h4 class="p">✔ $this from current scope supported in Closures</h4> - <pre><code data-trim class="php"> -class Foo { - private $prop = "bar"; + <pre><code>class Foo { + private $prop = "bar"; public function getPrinter() { - return function() { echo ucfirst($this->prop); }; + return function() { echo ucfirst($this->prop); }; } } $a = new Foo; -$func = $a->getPrinter(); +$func = $a->getPrinter(); $func(); // Outputs: Bar -?></code></pre> +?></code></pre> </section> <section id="php54page4"> <h4 class="p">✔ <?= is now always available</h4> @@ -267,22 +261,19 @@ $func(); // Outputs: Bar <ul> <li>JsonSerializable</li> </ul> - <pre><code data-trim class="php"> -class Foo implements JsonSerializable { + <pre><code>class Foo implements JsonSerializable { private $data = 'Bar'; public function jsonSerialize() { - return array('data'=>$this->data); + return array('data'=>$this->data); } } -echo json_encode(new Foo); // Outputs: {"data":"Bar"}</code></pre> +echo json_encode(new Foo); // Outputs: {"data":"Bar"}</code></pre> </section> <section id="php54page5"> <h4 class="p">✔ mysqlnd used by default everywhere</h4> <h4 class="p">✔ iterator support added to mysqli (mysqli_result implements Traversable)</h4> <h4 class="p">✔ Binary notation</h4> - <pre><code data-trim class="php"> -$mask = 0b010101; -</code></pre> + <pre><code>$mask = 0b010101;</code></pre> <h4 class="p">✔ AES Support added to OpenSSL</h4> <h4 class="p">✔ Tokyo Cabinet and DB5 support added to dba</h4> <h4 class="p">✔ Added stack frame count arg to debug_backtrace()</h4> @@ -314,26 +305,22 @@ PHP 5.4 + Opcache vs. PHP 5.3 + APC <section id="php54trip1"> <h2 margin-bottom="2em">Watch out for...</h2><br> <p class="p">✔ default charset is UTF-8 instead of ISO-8859-1</p> - <pre><code data-trim class="php"> -echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.3 "abc�def" -echo htmlspecialchars("abc".chr(0xE0)."def", NULL, 'UTF-8'); // 5.3 "" -echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.4 "" -echo htmlspecialchars("abc".chr(0xE0)."def", ENT_IGNORE); // 5.4 "abcdef"</code></pre> + <pre><code>echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.3 "abc�def" +echo htmlspecialchars("abc".chr(0xE0)."def", NULL, 'UTF-8'); // 5.3 "" +echo htmlspecialchars("abc".chr(0xE0)."def"); // 5.4 "" +echo htmlspecialchars("abc".chr(0xE0)."def", ENT_IGNORE); // 5.4 "abcdef"</code></pre> <p class="p">✔ array to string conversion notice</p> - <pre><code data-trim class="php"> -echo [1,2,3]; + <pre><code>echo [1,2,3]; // Notice: Array to string conversion in test.php code on line 1 array_diff([1,2,3], [1,2, [3] ]); -// Notice: Array to string conversion in test.php on line 2 -</code></pre> +// Notice: Array to string conversion in test.php on line 2</code></pre> <p class="p">✔ register_globals completely removed</p> <p class="p">✔ magic quotes completely removed</p> </section> <section id="php54trip2"> <p class="p">✔ removed variable break/continue</p> - <pre><code data-trim class="php"> -$var = 'label'; + <pre><code>$var = 'label'; while(1) { break $var; continue $var; @@ -344,16 +331,14 @@ label:</code></pre> </section> <section id="php54trip3"> <p class="p">✔ extending an abstract constructor must match the signature</p> - <pre><code data-trim class="php"> - abstract class Base { + <pre><code>abstract class Base { abstract public function __construct(); } class Foo extends Base { public function __construct($bar) {} // FATAL Declaration of Foo::__construct() must be compatible // with Base::__construct() - } -</code></pre> + }</code></pre> <p class="p">✔ stream_select() preserves keys of array arg</p> <p class="p">✔ XSLT writes are disabled by default</p> <p class="p">✔ mcrypt_generic_end() removed in favour of mcrypt_generic_deinit()</p> @@ -374,20 +359,18 @@ label:</code></pre> </section> <section id="generators"> <h4 class="p">✔ Generators</h4> - <pre><code data-trim class="php"> -function xrange($start, $end) { - for ($i = $start; $i <= $end; $i ++) { + <pre><code>function xrange($start, $end) { + for ($i = $start; $i <= $end; $i ++) { yield $i; } } foreach (xrange(0, 5) as $i) { - echo $i, "\n"; + echo $i, "\n"; }</code></pre> </section> <section id="finally"> <h4 class="p">✔ finally</h4> - <pre><code data-trim class="php"> -$db = mysqli_connect(); + <pre><code>$db = mysqli_connect(); try { call_some_function($db); } finally { @@ -396,96 +379,85 @@ try { </section> <section id="foreachlist"> <h4 class="p">✔ list() in foreach</h4> - <pre><code data-trim class="php"> -$names = [ ['John','Smith'], ['Fred','Johnson'] ]; + <pre><code>$names = [ ['John','Smith'], ['Fred','Johnson'] ]; foreach($names as list($first,$last)) { echo $first,$last; }</code></pre> </section> <section id="constarray"> <h4 class="p">✔ Const array/string Dereferencing</h4> - <pre><code data-trim class="php"> -echo array(1, 2, 3)[0]; //output 1 -echo "foobar"[3]; //output b + <pre><code>echo array(1, 2, 3)[0]; //output 1 +echo "foobar"[3]; //output b echo [1,3,4][2]; //output 4</code></pre> </section> <section id="others"> <h4 class="p">✔ empty() support for functions/expressions</h4> <h4 class="p">✔ curl upload functionality rewritten</h4> <h4 class="p">✔ Simplified password hashing API</h4> - <pre><code data-trim class="php"> -// Hash -$hash = password_hash("super secret",PASSWORD_BCRYPT); + <pre><code>// Hash +$hash = password_hash("super secret",PASSWORD_BCRYPT); // To validate $pwd against the stored hash if (password_verify($pwd, $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; -} -</code></pre> +}</code></pre> </section> </section> <section> <section id="php56"> <h2 margin-bottom="2em">PHP 5.6</h2><br> <h4 class="p">✔ Variadic functions</h4> - <pre><code data-trim class="php"> -class MySQL implements DB { + <pre><code>class MySQL implements DB { public function query($query, ...$params) { - $stmt = $this->pdo->prepare($query); - $stmt->execute($params); + $stmt = $this->pdo->prepare($query); + $stmt->execute($params); return $stmt; } } $q = 'SELECT * FROM users WHERE id = ?'; -$user = $db->query($q, $userID)->fetch();</code></pre> +$user = $db->query($q, $userID)->fetch();</code></pre> </section> <section id="php56unpack"> <h4 class="p">✔ Argument Unpacking</h4> - <pre><code data-trim class="php"> -// A better call_user_func_args + <pre><code>// A better call_user_func_args $args1 = [1, 2, 3]; $args2 = [4, 5, 6]; test(...$args1, ...$args2); // [1, 2, 3, 4, 5, 6] test(1, 2, 3, ...$args2); // [1, 2, 3, 4, 5, 6] test(...$args1, 4, 5, 6); // [1, 2, 3, 4, 5, 6]</code></pre> <h4 class="p">✔ Constant scalar expressions</h4> - <pre><code data-trim class="php"> -class Foo { + <pre><code>class Foo { const FOO = 1 + 1; - const BAR = 1 << 1; - const GREETING = "HELLO"; - const BAZ = self::GREETING." WORLD!" + const BAR = 1 << 1; + const GREETING = "HELLO"; + const BAZ = self::GREETING." WORLD!" }</code></pre> </section> <section id="php56pow"> <h4 class="p">✔ Add right-associative power operator **</h4> - <pre><code data-trim class="php"> -echo 2 ** 3 ** 2; // 512 (not 64) + <pre><code>echo 2 ** 3 ** 2; // 512 (not 64) echo -3 ** 2; // -9 (not 9) echo 1 - 3 ** 2; // -8 echo ~3 ** 2; // -10 (not 16)</code></pre> <h4 class="p">✔ Internal operator overloading for internal features like GMP</h4> - <pre><code data-trim class="php"> -echo 2**512; -echo "\n"; + <pre><code>echo 2**512; +echo "\n"; $n = gmp_init(2); -echo $n**512; -</code></pre> - <pre><code data-trim class="php">1.3407807929943E+154 +echo $n**512;</code></pre> + <pre><code>1.3407807929943E+154 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096 </code></pre> </section> <section id="php56use"> <h4 class="p">✔ use function and use const namespace imports</h4> - <pre><code data-trim class="php"> -include 'template.inc'; + <pre><code>include 'template.inc'; include 'db.inc'; use function template\header, template\footer, db\query; header('My Page'); query('select * from stuff'); -footer(); </code></pre> +footer();</code></pre> <h4 class="p">✔ SSL Peer verification by default</h4> <h4 class="p">✔ New phpdbg SAPI</h4> <h4 class="p">✔ Support for > 2GB file uploads</h4> @@ -572,7 +544,7 @@ footer(); </code></pre> // Optional libraries used to extend on reveal.js dependencies: [ { src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, - { src: '/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, + { src: '/highlight.pack.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '/reveal.js/plugin/zoom-js/zoom.js', async: true, callback: function() { return !!document.body.classList; } }, { src: '/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } } ] diff --git a/slides/intro/nold.xml b/slides/intro/nold.xml index 12edf12..8615e03 100644 --- a/slides/intro/nold.xml +++ b/slides/intro/nold.xml @@ -4,7 +4,7 @@ #include <ctype.h> #include <string.h> -#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && +#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && \ (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) int htoi(char *s) { diff --git a/sunshinephp14.html b/sunshinephp14.html index 407a326..0a1387c 100644 --- a/sunshinephp14.html +++ b/sunshinephp14.html @@ -18,7 +18,7 @@ <link rel="stylesheet" href="/samdark.css" id="theme"> <!-- For syntax highlighting --> - <link rel="stylesheet" href="/github.css"> + <link rel="stylesheet" href="/styles/github.css"> <!-- If the query includes 'print-pdf', include the PDF print sheet --> <script> @@ -67,20 +67,18 @@ </section> <section id="generators"> <h4 class="p">✔ Generators</h4> - <pre><code data-trim class="php"> -function xrange($start, $end) { - for ($i = $start; $i <= $end; $i ++) { + <pre><code>function xrange($start, $end) { + for ($i = $start; $i <= $end; $i ++) { yield $i; } } foreach (xrange(0, 5) as $i) { - echo $i, "\n"; + echo $i, "\n"; }</code></pre> </section> <section id="finally"> <h4 class="p">✔ finally</h4> - <pre><code data-trim class="php"> -$db = mysqli_connect(); + <pre><code>$db = mysqli_connect(); try { call_some_function($db); } finally { @@ -89,96 +87,85 @@ try { </section> <section id="foreachlist"> <h4 class="p">✔ list() in foreach</h4> - <pre><code data-trim class="php"> -$names = [ ['John','Smith'], ['Fred','Johnson'] ]; + <pre><code>$names = [ ['John','Smith'], ['Fred','Johnson'] ]; foreach($names as list($first,$last)) { echo $first,$last; }</code></pre> </section> <section id="constarray"> <h4 class="p">✔ Const array/string Dereferencing</h4> - <pre><code data-trim class="php"> -echo array(1, 2, 3)[0]; //output 1 -echo "foobar"[3]; //output b + <pre><code>echo array(1, 2, 3)[0]; //output 1 +echo "foobar"[3]; //output b echo [1,3,4][2]; //output 4</code></pre> </section> <section id="others"> <h4 class="p">✔ empty() support for functions/expressions</h4> <h4 class="p">✔ curl upload functionality rewritten</h4> <h4 class="p">✔ Simplified password hashing API</h4> - <pre><code data-trim class="php"> -// Hash -$hash = password_hash("super secret",PASSWORD_BCRYPT); + <pre><code>// Hash +$hash = password_hash("super secret",PASSWORD_BCRYPT); // To validate $pwd against the stored hash if (password_verify($pwd, $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; -} -</code></pre> +}</code></pre> </section> </section> <section> <section id="php56"> <h2 margin-bottom="2em">PHP 5.6</h2><br> <h4 class="p">✔ Variadic functions</h4> - <pre><code data-trim class="php"> -class MySQL implements DB { + <pre><code>class MySQL implements DB { public function query($query, ...$params) { - $stmt = $this->pdo->prepare($query); - $stmt->execute($params); + $stmt = $this->pdo->prepare($query); + $stmt->execute($params); return $stmt; } } $q = 'SELECT * FROM users WHERE id = ?'; -$user = $db->query($q, $userID)->fetch();</code></pre> +$user = $db->query($q, $userID)->fetch();</code></pre> </section> <section id="php56unpack"> <h4 class="p">✔ Argument Unpacking</h4> - <pre><code data-trim class="php"> -// A better call_user_func_args + <pre><code>// A better call_user_func_args $args1 = [1, 2, 3]; $args2 = [4, 5, 6]; test(...$args1, ...$args2); // [1, 2, 3, 4, 5, 6] test(1, 2, 3, ...$args2); // [1, 2, 3, 4, 5, 6] test(...$args1, 4, 5, 6); // [1, 2, 3, 4, 5, 6]</code></pre> <h4 class="p">✔ Constant scalar expressions</h4> - <pre><code data-trim class="php"> -class Foo { + <pre><code>class Foo { const FOO = 1 + 1; - const BAR = 1 << 1; - const GREETING = "HELLO"; - const BAZ = self::GREETING." WORLD!" + const BAR = 1 << 1; + const GREETING = "HELLO"; + const BAZ = self::GREETING." WORLD!" }</code></pre> </section> <section id="php56pow"> <h4 class="p">✔ Add right-associative power operator **</h4> - <pre><code data-trim class="php"> -echo 2 ** 3 ** 2; // 512 (not 64) + <pre><code>echo 2 ** 3 ** 2; // 512 (not 64) echo -3 ** 2; // -9 (not 9) echo 1 - 3 ** 2; // -8 echo ~3 ** 2; // -10 (not 16)</code></pre> <h4 class="p">✔ Internal operator overloading for internal features like GMP</h4> - <pre><code data-trim class="php"> -echo 2**512; -echo "\n"; + <pre><code>echo 2**512; +echo "\n"; $n = gmp_init(2); -echo $n**512; -</code></pre> - <pre><code data-trim class="php">1.3407807929943E+154 +echo $n**512;</code></pre> + <pre><code>1.3407807929943E+154 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096 </code></pre> </section> <section id="php56use"> <h4 class="p">✔ use function and use const namespace imports</h4> - <pre><code data-trim class="php"> -include 'template.inc'; + <pre><code>include 'template.inc'; include 'db.inc'; use function template\header, template\footer, db\query; header('My Page'); query('select * from stuff'); -footer(); </code></pre> +footer();</code></pre> <h4 class="p">✔ SSL Peer verification by default</h4> <h4 class="p">✔ New phpdbg SAPI</h4> <h4 class="p">✔ Support for > 2GB file uploads</h4> @@ -283,7 +270,7 @@ footer(); </code></pre> // Optional libraries used to extend on reveal.js dependencies: [ { src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, - { src: '/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, + { src: '/highlight.pack.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '/reveal.js/plugin/zoom-js/zoom.js', async: true, callback: function() { return !!document.body.classList; } }, { src: '/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } } ]