Skip to content

Latest commit

 

History

History
152 lines (144 loc) · 5.34 KB

php-cert-apr-2021.md

File metadata and controls

152 lines (144 loc) · 5.34 KB

PHP Test Prep -- 2021

TODO

  • Documentation on --enable-zend-multibyte

HOMEWORK

  • For Wed 5 May 2021
    • Quizzes for Section 7 (Functions)
    • Quizzes for Section 8 (OOP)
    • 2nd Mock Exam!!
  • For Mon 3 May 2021
    • Quizzes for Section 4 (Strings and Patterns)
    • Quizzes for Section 5 (Arrays)
    • Quizzes for Section 6 (I/O)
    • First Mock Exam!

Class Notes

OOP

Repo Setup:

Setup Docker / Docker Compose

Build the Image

  • Unzip the zip file provided by your instructor into a directory /path/to/repo
  • From a terminal windows (or command prompt):
cd /path/to/repo
docker-compose build
  • To run the image:
docker-compose up -d

Use the Image

  • To access the image from a browser:
http://10.30.30.30/php_cert
// or
http://localhost:8888/php_cert
  • To open a shell into the container:
    • From Linux:
docker exec -it php_cert /bin/bash
  • From Windows or Mac
    • Locate the running container in Docker Desktop
    • Click on the CLI >_ icon to open a shell
  • To access the database:
    • From the CLI: mysql -u root zend
  • Code examples are located (inside the container) in /srv/code

Past Notes:

ERRATA

  • 2/56/84: correct answer s/be B and C.
    • PSR-4 is only applicable if the question addresses directory structure and namespace.
    • Also, the test does not address the PSR standards.
    • Finally: the PSR-4 standard wasn't available when PHP 7.1 was introduced (verify)
  • 2/58/85: question contradicts the answer.
    • Mara + Kinga: D; Chloris: A
    • Better question: what is the output of the following?
      • A. "HelloWORLD" and a Notice
      • B. "HELLOWorld" and a Warning
      • C. "HelloWorld"
      • D. None of the above
<?php
// see: 02-58-85.php in this repo
namespace X {
    define('HELLO', 'Hello');
    const WORLD = 'World';
}
namespace Y {
    echo HELLO . WORLD;
}
// output: "HelloWORLD" + Notice: undefined constant
  • 2/67: Answer s/ have " 16"
  • 4/41/175: correct answer: 255 255.000000
  • 4/57: old question left over from PHP 5.5 exam: ignore
    • Should be rewritten as follows: "C. The zend.multibyte php.ini setting must be enabled"
  • 5/17: array_search(): Returns element key value, or boolean false. A third boolean parameter includes type checking.
  • Mock Exam #2: "Given that $fp is a stream resource, enter the function that outputs a file's contents"
    • Correct Answer: fpassthru
  • 12/8/???: "Aggregate Catch Blocks"
    • Example doesn't help. How about this:

try {
    $pdo = new PDO($params);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException | ArgumentCountException $e) {
    error_log('Database error: ' . date('Y-m-d H:i:s'));
} finally {
    echo 'Database connection ';
    echo ($pdo) ? 'succeeded' : 'failed';
}
  • Mock Exam 2
    • "Of the options given, which satisfy the array type hint?"
      • There is not array type hint!