Errata

Programming PHP

Errata for Programming PHP

Submit your own errata for this product.

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
PDF Page p.134
3rd code snippet

In the code snippet, an apostrophe was used instead of a quotation mark in the end of the line: $subjects = array("physics", "chem", "math');

Charles  Nov 08, 2023 
PDF Page 12
Example 1-4

There is colspan="4" in the first row of the table but the table only has three colums. I guess that it would be better to use colspan="3" there.

Bastian Holtermann  Jan 04, 2021 
PDF Page 13
Example 1-5

The function imagecolorallocate is called with $im. But $im isn't used anywhere else in the example. Therefore I guess that $im should be $image there.

Bastian Holtermann  Jan 04, 2021 
Printed, PDF Page 13
code

The code on graphics in 'introduction to PHP' section where it says "a text entry field that lets the user specify the text for a button. It takes an empty button image file, and centers the text passed as the GET parameter 'message' on it. The result is then sent back to the browser as a PNG image." this gives numerous warning and fatal errors as the code has huge amount of bugs, this is just one of the warnings given...Warning: imagettfbbox(): Invalid font filename in C:\wamp64\www\button.php on line 7, please let me know how to fix this as this a bug from the book.










Anonymous  Apr 13, 2021 
Printed, PDF Page 13
Example 1-5


The code on graphics in 'introduction to PHP Example 1-5' section where it says "a text entry field that lets the user specify the text for a button. It takes an empty button image file, and centers the text passed as the GET parameter 'message' on it. The result is then sent back to the browser as a PNG image." this gives numerous warning and fatal errors as the code has huge amount of bugs, this is just one of the warnings given...Warning: imagettfbbox(): Invalid font filename in C:\wamp64\www\button.php on line 7, please let me know how to fix this as this a bug from the book.

Frederick Carter  Apr 13, 2021 
PDF Page 23
Floating-Point Numbers

On that page there is a range for floating point numbers given that is this: 1.7E-308 and 1.7E+308.
But that only describes the values greater than zero. What about the floating point numbers with a value lower than zero?

Bastian Holtermann  Jan 07, 2021 
Other Digital Version 34
Example 1-5 line 6

Kindle edition. The file button.png is missing. This program can't run without it. Also, as noted by another comment, $im should be $image.

Chris  Feb 25, 2021 
PDF Page 36
Table 2-3. PHP operators

For the operator '!==' the described operation in the book is 'Type and value inequality'.

I would prefer 'Type or value inequality' since
42 !== 21 is true because the value is different but the type is equal and
42 !== 42.0 is true because the value is equal but the type is different.

But I am not sure because the operation checks for 'Type and value inequality' but it returns true also if only one is inequal.

Perhaps a footnote could be introduced to give some clarifying information on that.

Bastian Holtermann  Feb 04, 2021 
PDF Page 43
Bitwise AND (&) example in the middle of the page

In the PDF ebook the second value of the operand is not located bitwise under the value of the first operand but shifted one space to the right.

It would be easier to see the operation if the values were exactly under each other.

Bastian Holtermann  May 11, 2021 
PDF Page 96
Code example

// $string is "hello\tworld\n" should be // $string is "hello world"

Worawit Lalitkiattikool  Nov 20, 2022 
Printed Page 116
Fourth Example

should be print_r($match) ; instead of matche.

Sean  Jan 21, 2024 
PDF Page 131
3rd §

On p.131, it says:

"It is generally only meaningful to use array_slice() on indexed arrays (i.e., those with consecutive integer indices starting at 0):
// this use of array_slice() makes no sense
$person = array('name' => "Fred", 'age' => 35, 'wife' => "Betty");
$subset = array_slice($person, 1, 2); // $subset is array(0 => 35, 1 => "Betty")"

However, when running this code, the output is not array(0 => 35, 1 => "Betty") but array([age] => 35, [wife] => Betty). In this case, it is meaningful to use array_slice() because the key→value pair is kept intact.

Charles  Nov 08, 2023 
Printed Page 137
1st paragraph

Regarding the each() iterator function:
As per php.net (https://www.php.net/manual/en/function.each.php),

Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

GF  Oct 19, 2020 
Printed Page 213
"Once the session is started, the $bg and $fg variables are created and all the script has to do is use them"

"Once the session is started, the $bg and $fg variables are created and all the script has to do is use them"But that's not what the code listing (8-14) shows. The code listing illustrates explicitly reading values from the $_SESSION array.


This one is the clearest example, but the whole section on sessions seems to have this split-brain about variable registration. The text talks about sessions as if you can register variables to be automatically loaded and saved to the session. But the example code never shows variable registration, it only shows $_SESSION array interactions.

I did a little more research on this. It looks like session registration for variables was deprecated in PHP 5.4 and removed since then. Chapter 8 looks like it was lightly rewritten to remove any explicit reference to functions like session_register(), but the text still reads as if the variable registration API exists. It's rather disconcerting in contrast to the code examples.

Avdi Grimm  Mar 22, 2022 
Printed Page 366
bottom

The "catch" section of the try/catch block at the bottom of the page looks like it has an exposed text formatting command, "\ParseException". There is an unbalanced curly brace and parenthesis.

Andrew Siegel  Jan 22, 2021