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
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