SlideShare uma empresa Scribd logo
1 de 31
Trucs & astuces PHP
.:PHP:.







web interpreted language
Auto. memory management
Weakly typed
Highly dynamic
Light and efficient
Cross-plateform
PHP gotcha !
 Highly dynamic language
 Borrows some concepts from perl / C

 Lots of weird behaviors
 To be known

 Certification exam can fool you with such behaviors
PHP gotcha

if (DONT_EXIST) {
echo "true";
} else {
echo "false";
}
PHP gotcha revealed
if (DONT_EXIST) {
echo "true";
} else {
echo "false";
}

if ("DONT_EXIST")

if (true)
PHP gotcha

$text = "foo and bar";
if (strpos($text, "foo") {
echo "foo is here";
} else {
echo "foo is not here";
}
PHP gotcha

echo (true?'true':false?'t':'f');
PHP gotcha revealed

echo (true?'true':false?'t':'f');

echo ( (true?'true':false) ?'t':'f' );
PHP gotcha

$a = 'foobar';
$a[10] = 'foo';
var_dump($a);
PHP gotcha revealed

$a = 'foobar';
$a[10] = 'foo';
var_dump($a);

string(11) "foobar

f"
PHP gotcha

$a = 11;
$a = $a++ + ++$a;
echo $a++;
PHP gotcha revealed
$a = 11;
$a = $a++ + ++$a;
echo $a++;

$a = 11;
$a = 11 + 13; //24
echo 24;
PHP gotcha
$array = array(1 => "Julien", "1" => "Seb", "Mag", 2 => "Leo");
echo count($array);
PHP gotcha revealed
$array = array(1 => "Julien", "1" => "Seb", "Mag", 2 => "Leo");
echo count($array);

$array = array( "1" => "Seb", 2 => "Leo");
2
PHP gotcha
$a = 'foo';
$b = 'bar';
echo $a . print('baz') . $b;
PHP gotcha revealed
$a = 'foo';
$b = 'bar';
echo $a . print('baz') . $b;

echo $a . print("baz" . $b);
"bazbarfoo1"
PHP gotcha

echo 0123 + 123 + 0;
PHP gotcha revealed

echo 0123 + 123 + 0;

echo 83 + 123 + 0;
PHP gotcha

$a = 'baz';
$a++;
echo $a;
PHP gotcha revealed

$a = 'baz';
$a++;
echo $a;

"bba"
PHP Tips
 PHP is full of functions and extensions
 Let's oversee some useful features
PHP Tip
 Array Flattening
$input = array('a', 'b', array('c', 'd'), 'e', array('f'), 'g');
$output = iterator_to_array(new RecursiveIteratorIterator(
new RecursiveArrayIterator($input)), FALSE);
var_dump($output);

array('a', 'b', 'c', 'd', 'e', 'f', 'g');
PHP Tip
 Automatic HTML cleaning
ob_start('ob_tidyhandler');
echo '<p>test</i>';

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title></title>
</head>
<body>
<p>test</p>
</body>
</html>
PHP Tip
 Get usefull info from MySQL
mysqli_report(MYSQLI_REPORT_INDEX);
$db = mysqli_connect('srv1', 'john', 'secret', 'my_db');
mysqli_query($db, "SELECT photo FROM Users WHERE source !='' LIMIT 1000");

PHP Warning: mysqli_query(): (00000/0): No index used in query/prepared
statement SELECT photo FROM Users WHERE source !='' LIMIT 1000
PHP Tip
 Apply a callback to every fetch from MySQL

$sql = "SELECT nom, prenom FROM auteurs";
$stmt = $pdo->query($sql);
$func = function ($nom, $prenom){printf('%s-%s',$nom,$prenom);};
$result = $stmt->fetchAll(PDO::FETCH_FUNC, $func);
PHP Tip
 List a type of weekday coming in calendar
$begin = new DateTime('2009-11-01');
$end = new DateTime; // now
$interval = DateInterval::createFromDateString('next sunday');
$period = new DatePeriod($begin, $interval, $end);
foreach ( $period as $dt ) {
echo $dt->format( "l Y-m-d H:i:sn" );
}

Sunday 2009-11-01 00:00:00
Sunday 2009-11-08 00:00:00
Sunday 2009-11-15 00:00:00
...
PHP Certification
 70 Questions – 90min
 PHP 5.5
 Functions – OOP – arrays – streams – Xml – Databases –
Json – strings – securité – Ios – HTTP ...
 Nothing known about how to pass the exam
 Better know maximum of subjects
PHP certif quick overview
What's the output of this script ?
<?php
function oranges(&$oranges = 17) {
$oranges .= 1;
}
$apples = 5;
oranges($apples);
echo $apples++;
A)16
B)51
C)15
D)6
E)52
PHP certif quick overview
What's design pattern can you recognize ?
<?php
class MyClassBuilder {
public function build() {
return new MyClass();
}
}
A)builder
B)factory
C)singleton
D)observer
E)other pattern
PHP certif quick overview
In SimpleXML, you can use ______ method on SimpleXmlElement
to get all its children
PHP certif quick overview
What's the output of this script ?
<?php
class Foo {
const BAR = 4+1;
}
echo Foo::BAR;
A)4
B)5
C)1
D)an error

Mais conteúdo relacionado

Mais procurados

Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
Moriyoshi Koizumi
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
Xinchen Hui
 

Mais procurados (20)

Php and threads ZTS
Php and threads ZTSPhp and threads ZTS
Php and threads ZTS
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
 
Php engine
Php enginePhp engine
Php engine
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension review
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
 
Php string function
Php string function Php string function
Php string function
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
 
SymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesSymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performances
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
Modern PHP
Modern PHPModern PHP
Modern PHP
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performances
 

Semelhante a PHP Tips for certification - OdW13

GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
Nat Weerawan
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
Lin Yo-An
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
 

Semelhante a PHP Tips for certification - OdW13 (20)

[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Introduction to PHP Lecture 1
Introduction to PHP Lecture 1Introduction to PHP Lecture 1
Introduction to PHP Lecture 1
 
PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
 
Php hacku
Php hackuPhp hacku
Php hacku
 
Clear php reference
Clear php referenceClear php reference
Clear php reference
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
 
Automated code audits
Automated code auditsAutomated code audits
Automated code audits
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
 
Top 10 php classic traps DPC 2020
Top 10 php classic traps DPC 2020Top 10 php classic traps DPC 2020
Top 10 php classic traps DPC 2020
 
PHP for hacks
PHP for hacksPHP for hacks
PHP for hacks
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 

Mais de julien pauli

Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
julien pauli
 
Understanding PHP memory
Understanding PHP memoryUnderstanding PHP memory
Understanding PHP memory
julien pauli
 
Communications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHPCommunications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHP
julien pauli
 
PHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_ExtensionsPHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_Extensions
julien pauli
 
PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4
julien pauli
 
Patterns and OOP in PHP
Patterns and OOP in PHPPatterns and OOP in PHP
Patterns and OOP in PHP
julien pauli
 

Mais de julien pauli (16)

Doctrine with Symfony - SymfonyCon 2019
Doctrine with Symfony - SymfonyCon 2019Doctrine with Symfony - SymfonyCon 2019
Doctrine with Symfony - SymfonyCon 2019
 
Dns
DnsDns
Dns
 
Basics of Cryptography - Stream ciphers and PRNG
Basics of Cryptography - Stream ciphers and PRNGBasics of Cryptography - Stream ciphers and PRNG
Basics of Cryptography - Stream ciphers and PRNG
 
Mastering your home network - Do It Yourself
Mastering your home network - Do It YourselfMastering your home network - Do It Yourself
Mastering your home network - Do It Yourself
 
Tcpip
TcpipTcpip
Tcpip
 
PHP 7 new engine
PHP 7 new enginePHP 7 new engine
PHP 7 new engine
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
Understanding PHP memory
Understanding PHP memoryUnderstanding PHP memory
Understanding PHP memory
 
Communications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHPCommunications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHP
 
PHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_ExtensionsPHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_Extensions
 
PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4
 
Patterns and OOP in PHP
Patterns and OOP in PHPPatterns and OOP in PHP
Patterns and OOP in PHP
 
ZendFramework2 - Présentation
ZendFramework2 - PrésentationZendFramework2 - Présentation
ZendFramework2 - Présentation
 
AlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPAlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHP
 
Apache for développeurs PHP
Apache for développeurs PHPApache for développeurs PHP
Apache for développeurs PHP
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

PHP Tips for certification - OdW13

  • 2. .:PHP:.       web interpreted language Auto. memory management Weakly typed Highly dynamic Light and efficient Cross-plateform
  • 3. PHP gotcha !  Highly dynamic language  Borrows some concepts from perl / C  Lots of weird behaviors  To be known  Certification exam can fool you with such behaviors
  • 4. PHP gotcha if (DONT_EXIST) { echo "true"; } else { echo "false"; }
  • 5. PHP gotcha revealed if (DONT_EXIST) { echo "true"; } else { echo "false"; } if ("DONT_EXIST") if (true)
  • 6. PHP gotcha $text = "foo and bar"; if (strpos($text, "foo") { echo "foo is here"; } else { echo "foo is not here"; }
  • 8. PHP gotcha revealed echo (true?'true':false?'t':'f'); echo ( (true?'true':false) ?'t':'f' );
  • 9. PHP gotcha $a = 'foobar'; $a[10] = 'foo'; var_dump($a);
  • 10. PHP gotcha revealed $a = 'foobar'; $a[10] = 'foo'; var_dump($a); string(11) "foobar f"
  • 11. PHP gotcha $a = 11; $a = $a++ + ++$a; echo $a++;
  • 12. PHP gotcha revealed $a = 11; $a = $a++ + ++$a; echo $a++; $a = 11; $a = 11 + 13; //24 echo 24;
  • 13. PHP gotcha $array = array(1 => "Julien", "1" => "Seb", "Mag", 2 => "Leo"); echo count($array);
  • 14. PHP gotcha revealed $array = array(1 => "Julien", "1" => "Seb", "Mag", 2 => "Leo"); echo count($array); $array = array( "1" => "Seb", 2 => "Leo"); 2
  • 15. PHP gotcha $a = 'foo'; $b = 'bar'; echo $a . print('baz') . $b;
  • 16. PHP gotcha revealed $a = 'foo'; $b = 'bar'; echo $a . print('baz') . $b; echo $a . print("baz" . $b); "bazbarfoo1"
  • 17. PHP gotcha echo 0123 + 123 + 0;
  • 18. PHP gotcha revealed echo 0123 + 123 + 0; echo 83 + 123 + 0;
  • 19. PHP gotcha $a = 'baz'; $a++; echo $a;
  • 20. PHP gotcha revealed $a = 'baz'; $a++; echo $a; "bba"
  • 21. PHP Tips  PHP is full of functions and extensions  Let's oversee some useful features
  • 22. PHP Tip  Array Flattening $input = array('a', 'b', array('c', 'd'), 'e', array('f'), 'g'); $output = iterator_to_array(new RecursiveIteratorIterator( new RecursiveArrayIterator($input)), FALSE); var_dump($output); array('a', 'b', 'c', 'd', 'e', 'f', 'g');
  • 23. PHP Tip  Automatic HTML cleaning ob_start('ob_tidyhandler'); echo '<p>test</i>'; <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title></title> </head> <body> <p>test</p> </body> </html>
  • 24. PHP Tip  Get usefull info from MySQL mysqli_report(MYSQLI_REPORT_INDEX); $db = mysqli_connect('srv1', 'john', 'secret', 'my_db'); mysqli_query($db, "SELECT photo FROM Users WHERE source !='' LIMIT 1000"); PHP Warning: mysqli_query(): (00000/0): No index used in query/prepared statement SELECT photo FROM Users WHERE source !='' LIMIT 1000
  • 25. PHP Tip  Apply a callback to every fetch from MySQL $sql = "SELECT nom, prenom FROM auteurs"; $stmt = $pdo->query($sql); $func = function ($nom, $prenom){printf('%s-%s',$nom,$prenom);}; $result = $stmt->fetchAll(PDO::FETCH_FUNC, $func);
  • 26. PHP Tip  List a type of weekday coming in calendar $begin = new DateTime('2009-11-01'); $end = new DateTime; // now $interval = DateInterval::createFromDateString('next sunday'); $period = new DatePeriod($begin, $interval, $end); foreach ( $period as $dt ) { echo $dt->format( "l Y-m-d H:i:sn" ); } Sunday 2009-11-01 00:00:00 Sunday 2009-11-08 00:00:00 Sunday 2009-11-15 00:00:00 ...
  • 27. PHP Certification  70 Questions – 90min  PHP 5.5  Functions – OOP – arrays – streams – Xml – Databases – Json – strings – securité – Ios – HTTP ...  Nothing known about how to pass the exam  Better know maximum of subjects
  • 28. PHP certif quick overview What's the output of this script ? <?php function oranges(&$oranges = 17) { $oranges .= 1; } $apples = 5; oranges($apples); echo $apples++; A)16 B)51 C)15 D)6 E)52
  • 29. PHP certif quick overview What's design pattern can you recognize ? <?php class MyClassBuilder { public function build() { return new MyClass(); } } A)builder B)factory C)singleton D)observer E)other pattern
  • 30. PHP certif quick overview In SimpleXML, you can use ______ method on SimpleXmlElement to get all its children
  • 31. PHP certif quick overview What's the output of this script ? <?php class Foo { const BAR = 4+1; } echo Foo::BAR; A)4 B)5 C)1 D)an error