Skip to content

Latest commit

 

History

History
153 lines (127 loc) · 5.92 KB

php-cert-aug-2020.md

File metadata and controls

153 lines (127 loc) · 5.92 KB

PHP Test Prep -- Aug 2020

Working Schedule

  • Tue 04 Aug: up to Mod 3 XML
  • Thu 06 Aug: 3 - 4 + deliver 1st Mock
  • Tue 11 Aug: Review Mock 1 + Mod 5 - 7 (partial)
  • Thu 13 Aug: Finish Mods 7 and 8 + Deliver Mock 2
  • Tue 18 Aug: Review Mock 2 + 9 - 10 + deliver Mock Final
  • Thu 20 Aug: 11 - 12 + Review Mock Final

TODO

Q & A

  • Q: Can an Interface contain properties?
  • A: No. If you try to add a property, this message will result:
PHP Fatal error:  Interfaces may not include member variables in ...

Class Notes

Test Logistics

Bitwise Operations

Bitwise AND
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1

Bitwise OR
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1

Bitwise XOR
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0
echo ~(($a | $b) ^ $c) ? 'T' : 'F';
// from Catalin-Marius to All Participants:
(0010 | 0101) = 0111 ^ 0111 = ~0000 = 1111 => 'T'

XPath / XML

SOAP

DateTime

Strings

  • Be "glancingly familiar" with the string functions, especially those starting with str*
    • Letter i indicates case-insensitive
    • Letter r indicates in reverse
    • Letter u indicates user-defined callback
  • printf family
    • Format codes documents under sprintf
    • Make sure you understand the basic format codes

Regex

Various preg* examples: https://github.com/dbierer/classic_php_examples/tree/master/regex

Arrays

Summary of array add and remove functions:

  array_push() array_pop() array_shift() array_unshift()
Adds to the array X     X
Removes from the array   X X  
Beginning of the array     X X
End of the array X X    
Returns the new array count X     X
Returns the removed element   X X  

Anonymous Functions

Reference to Closure class: https://www.php.net/closure

OOP

  • Example on PDF page 297 (slide 8/16) generates warning, which was fixed in PHP 7.4:
Warning: Declaration of Container\ControllerServiceContainer::set(string $name, $value) should be compatible with Container\ServiceContainer::set($name, $value)
  • Example on PDF page 308 (slide 8/27): use syntax should be as follows. Curly braces are not appropriate in this situation.
use FactoryInterface, IndexControllerFactory;
  • Example on PDF page 308 (slide 8/27): the abstract method set() is not defined which means a fatal error will be generated

Generators and Delegating Generators

Magic Methods

You will be responsible for all magic methods except for:

SPL

Make sure you are "glancingly familiar" with the SPL

Late Static Binding

Read the explanation: https://www.php.net/manual/en/language.oop5.late-static-bindings.php

Traits

  • Traits are affected by namespace
  • Make sure you're familiar with use / as / insteadof with reference to traits
  • Study traits keywords "as" and "insteadof"
  • https://www.php.net/traits

Security

random_int(int $min, int $max);

Database

Notes from PDO::bindValue():

  • What the bindValue() docs fail to explain without reading them very carefully is that bindParam() is passed to PDO byref - whereas bindValue() isn't. Thus with bindValue() you can do something like $stmt->bindValue(":something", "bind this"); whereas with bindParam() it will fail because you can't pass a string by reference, for example.
  • http://localhost:8888/#/9/26: PDOException is never thrown because the error mode is not set!

Exceptions

ERRATA

  • 2/57 correct answer s/be B and C. PSR-4 is only applicable if the question addresses directory structure and namespace
  • 4/42: correct answer: 255 255.000000
  • 5/17: array_search(): Returns element key value, or boolean false. A third boolean parameter includes type checking.