Errata

Modern PHP

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date Submitted
Mobi E Tyz Mtnpqvuo

Hello there,

My name is George and I'd like to know if you would have some interest to have your website here at oreilly.com promoted as a resource on our blog georgemartjr.com ?

We are updating our broken link resources to include current and up to date resources for our readers. Our resource links are manually approved allowing us to mark a link as a do-follow link as well
.
If you may be interested please in being included as a resource on our blog, please let me know.

Thanks,
George

Anonymous  Feb 28, 2019 
Printed Page 126
Example 5-44

Example 5-19 shows the proper way to handle confidential credentials; so I have to wonder why Example 5-44 does not follow suit?

IMO Example 5-44 should be rewritten to include a separate settings.php file for the username and password credentials, and the email names and addresses.

Jim  Jan 28, 2018 
Printed Page 97-101
Code at top of page 97; Examples 5-20, 5-21, 5-22, 5-23, 5-24, and 5-25

As separately reported for Examples 5-7 & 5-8, filter_input() is missing one or more filter flags.

Jim Kovacs  Jan 28, 2018 
Printed Page 53
Fourth sentence

Mocked?

"Its concerns are few, and its dependencies can be easily identified and mocked."

Jim Kovacs  Jan 28, 2018 
Printed Page 85
Example 5-8 lines 5 and 8

As separately reported for Example 5-7, filter_input() is missing one or more filter flags.

E.g., compare Example 5-7 line 4 (page 83) with Example 5-8 line 5 (page 85).

Jim Kovacs  Jan 28, 2018 
Printed Page 84
Lines 17-19

Lines 17-19 should be indented four spaces (not three) per PSR-2, 2.4 Indenting. See also 4.6. Method and Function Calls, whose second example indents four spaces.

Jim Kovacs  Jan 28, 2018 
Printed Page 84
Line 10 of Example 5-7

Line 10 does not use the optional third parameter ('filter'). In this case, according to the PHP manual:

If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default.

So one or more filter flags should be added to filter_input() on line 10.

Jim Kovacs  Jan 28, 2018 
Printed Page 80
Escape Output

You may want to mention this regarding "specify the appropriate character encoding (usually UTF-8) as the third argument":

[Quoted from PHP manual]

default_charset string

In PHP 5.6 onwards, "UTF-8" is the default value and its value is used as the default character encoding for htmlentities(), html_entity_decode() and htmlspecialchars() if the encoding parameter is omitted.

[/quote]

Jim Kovacs  Jan 27, 2018 
Printed Page 78 & 79
User Profile Information (p. 78) & Validate Data (p. 79)

Page 78 mentions filter_var() and filter_input(), and Examples 5-3, 5-4, and 5-5 illustrate filter_var() usage; why did you not include at least one example of filter_input() usage?

Jim Kovacs  Jan 27, 2018 
Printed Page 78
2nd paragraph

It's incorrect to use "zip code" -- the correct usage is ZIP Codeā„¢ (first instance; 'ZIP Code' for subsequent instances).

Jim Kovacs  Jan 27, 2018 
Printed Page 40
Sentence above bullet list

The sentence above the bullet list uses "five recommendations" while the list consists of six recommendations.

Jim Kovacs  Jan 27, 2018 
Printed Page 77
2nd paragraph

The text describing Example 5-1 uses "The second argument is the ENT_QUOTES constant, which prompts the function to encode single quotes." when in fact this constant "Will convert both double and single quotes." according to the manual.

Jim Kovacs  Jan 26, 2018 
Printed Page 208
Mentoring

phpmentoring.org is not what's described under Mentoring.

Did you mean php-mentoring.org?

Jim Kovacs  Jan 23, 2018 
Printed Page 113
Example 5-35

Should

class DirtyWordsFilter extends php_user_filter

be this instead

class DirtyWordsFilter extends \php_user_filter

since this new class would presumably reside in its own namespace?

Jim Kovacs  Jan 23, 2018 
Printed Page 106 & 107

The penultimate paragraph on page 106 uses http: for the URL while the first paragraph under Stream Wrappers on page 107 uses https:.

Both URLs work of course; it's just a matter of consistency.

Jim Kovacs  Jan 23, 2018 
Printed Page 102 & 103
Examples 5-26 & 5-27

Example 5-19 on page 96 uses include('../settings.php') while examples 5-26 & 5-27 use require 'settings.php'.

../settings.php is correct because this file must be located outside the document root.

Jim Kovacs  Jan 23, 2018 
Printed Page 65
Paragraph preceding Note

I made a mistake; disregard my previous submission because the book is correct.as-is regarding Composer's global credentials being saved in %APPDATA%/Composer.

Jim Kovacs  Jan 22, 2018 
Printed Page 65
Paragraph preceding Note

Using Composer version 1.6.2 2018-01-05 for Windows, global credentials are saved in %APPDATA%/ComposerSetup

Jim Kovacs  Jan 22, 2018 
Printed Page 62
composer commands

Using Composer version 1.6.2 2018-01-05 for Windows, the two composer commands shown on page 62 must not have the trailing semicolon; otherwise composer issues an InvalidArgumentException:

C:\...\url-scanner-app>composer require guzzlehttp/guzzle;

[InvalidArgumentException]
Could not find package guzzlehttp/guzzle;.

Did you mean one of these?
guzzlehttp/guzzle
puzzlehttp/puzzle
guzzle/guzzle
guzzlehttp/guzzle-services
forknetwork/guzzle3

Jim Kovacs  Jan 22, 2018 
Other Digital Version Code
Code

The answer to my previous question was found on page 42: PSR-2 Strict Code Style "must not include a trailing ?> PHP tag."

Jim Kovacs  Jan 21, 2018 
Other Digital Version Code
Code

Why is the closing ?> tag absent from the PHP files included in the book's downloadable code? (The opening <?php is present, but not the closing ?> tag.)

Jim Kovacs  Jan 21, 2018 
Printed Page 22
Example 2-15

2016-02-26 edition of book uses "simpleGenerator" as the name of the function whereas the first bit of code on page 23 uses "myGenerator", as does the code available for download (modern-php-master\02-features\generators\simple-generator.php)

Jim Kovacs  Jan 21, 2018