PHP — The basics

Guide 04 / 4

Resources and review

Learn to consult documentation, solve an error and check what you have learned.

Expected outcome :

Find reliable information and explain what you have built.

Reading
0%

01 · Reading and exploring the PHP manual

The reference links appear below.

Manual · PHP tutorial

Follow the first pages of the tutorial then find where the server runs the code. Compare the file's code with the source code received by the browser.

Mission : confirmer que le tableau PHP ne figure pas dans le HTML reçu.

Manual · htmlspecialchars and filters

Read the parameters used by h and the options of FILTER_VALIDATE_INT. Spot the return types, especially false.

Mission : expliquer pourquoi on écrit $duree === false.

Manual · Built-in server and mbstring

Read how the local server is used and check the mb_strlen and mb_stripos functions used in the examples.

Mission : retrouver les extensions disponibles avec php -m.

02 · Troubleshooting and review

The terminal that starts the server holds the useful messages.

The PHP appears as text or the page is blank

Check that the URL uses the PHP server and not file:// or a static server. For a blank page, look at the terminal and check the syntax.

php -l public/index.php
Remember :

A syntax error must be fixed before continuing the functional tests.

mb_* function missing or require failing

A missing mb_* function means mbstring is not enabled in the PHP being used. A failing require indicates an incorrect path or name; starting from __DIR__ helps check it.

php -m
Chemin attendu : mini-blog/includes/functions.php

Self-assessment and moving on to MySQL

Explain request-response, array, loop, validation and escaping. Create a recipe in the array and check its page. Explain why a submission does not yet survive as a new recipe.

Je sais :
□ exécuter PHP via HTTP ;
□ produire du HTML depuis un tableau ;
□ lire un paramètre GET ;
□ contrôler un POST ;
□ échapper les textes affichés.
Remember :

Next: MySQL will store the recipes and categories durably; PDO will replace loading the array.