Errata

Learning PHP

Errata for Learning 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
Other Digital Version WebSite
Download Sample Code

Download sample code: Very cryptic group of folders. Should have folders labeled: Chapter 11, Chapter 5, etc.... Then inside folder files labeled example 11-3, 11-8, 5-9, 5-12.

The existing list of downloadable code is alphabetical and has no direct correlation between name of file in book and name of file on web site.

Impossible to find content.

Anonymous  Jul 09, 2016 
Printed Page 2
Figure 1-2

In Stage 2 of Figure 1-2, The computer incorrectly asks for catalog.html instead of yak.php (which is shown in Stage 1 of Figure 1-2)

Thomas Morelli  Jun 06, 2016 
Printed Page 7
Code Example 1-2, line 4

In the button element tag on line 4, there is an unnecessary quotation mark.
<button type="submit"">
should be
<button type="submit">

Anonymous  May 25, 2016 
Printed Page 10
Example 1-5

if ($_POST['user'])

should be

if (isset($_POST['user']))

in order to prevent PHP Notice: Undefined index: user

Jim Kovacs  Jan 27, 2018 
PDF Page 29rus
Example 1-5

if ($_POST['user']) {
print "Hello,
print $_POST['user'];
print "!";

should be

<?php
if (isset($_POST['user'])) {
print "Hello";
print $_POST['user'];
print "!";
}

Fantast  Jan 04, 2019 
Printed Page 49
4th paragraph

Quote: It evaluates to a negative number when its lefthand operand is less than the righthand operand, a positive number when the righthand operand is bigger, and 0 when they are equal.

To me it seems that the righthand operand is bigger when the lefthand operarand is less than the righthand operand. Either swap left/right and keep bigger the same or swap bigger/less and keep left/right the same

Tristan Linnenbank  Dec 12, 2016 
PDF Page 50
1st paragraph

Quote:The string "6 pack" is greater than the string "55 card stud"

is incorrect because "6 pack" compared to "55 card stud" using <=> operator evaluates to -1 which is less than 0.

<=> operator evaluates the strings to numbers like > or < operators and so 6 is smaller than 55.

Anonymous  May 28, 2017 
Printed Page 97
First paragraph, second line

In the first paragraph, a closing ')' is missing.

The only difference between Example 5-9 and Example 5-24 is the int after countdown (and before $top. ...
/\
|
This brace is not closed

Anonymous  Jun 01, 2016 
Printed Page 129
Very last line on page, last line of code

Last line of code on that page has an equals sign which should not be there:
function show_form($errors = ) {

program will not work unless you remove the equal sign:

function show_form($errors ) {

PVP  Jul 11, 2016 
Printed Page 135
Example 7-16

Since strtotime function seems to be unnecessary,

if ($input['year'] && input['month'] && input['day'] &&
checkdate($input['month'], $input['day'], $input['year'])) {
$submitted_date = new DateTime(strtotime($input['year'] . '-' .
$input['month'] . '-' .
$input['day']));

should be:

if ($input['year'] && $input['month'] && $input['day'] &&
checkdate($input['month'], $input['day'], $input['year'])) {
$submitted_date = new DateTime($input['year'].'-'.
$input['month'].'-'.
$input['day']);


Ryoko  Dec 24, 2019 
Printed Page 137
1st paragraph of code

Example 7-18 p. 136-137 shows a closing select tag while no opening select tag exists:

// Display the form
function show_form( ) {
$sweets = generate_options($GLOBALS['sweets']);
print<<<_HTML_
<form method="post" action="$_SERVER[PHP_SELF]">
Your Order: <select name="order">
$sweets
</select>
<br/>
<input type="submit" value="Order">
</form>
_HTML_;
}

david hahn  Aug 28, 2018 
Printed Page 146
attributes function

The attributes function, as written, does not work with radio buttons. If the example is typed in (including the code headed "Example 7-30" and "Example 7-31", the "Size" radio buttons are generated as follows:
<tr><td>Size:</td>
<td><input name="size" value="medium" type="radio" />Small<br/>
<input name="size" value="medium" type="radio" checked />Medium<br/>
<input name="size" value="medium" type="radio" />Large<br/>
</td></tr>

In other words, all of them have same 'value'. This is due to the "if ($valueAttribute &&..." clause in FormHelper::attributes. It should have an extra check: if we are creating a control of a type where multiple controls have the same name but different values, don't change the value.

Ian Barkley-Yeung  Jun 04, 2017 
Printed Page 151
Bottom Of Page

Maybe I'm missing something but the code in Example 7-31 "PHP and HTML generating a form" doesn't work.

<?= $form->input('radio',['name' => 'size', 'value => 'small']) ?>

I've check on the official PHP.net site and numerous web sites for assistance and none of them mention the above code as a way of creating a web form.

It certainly doesn't work for me.

PVP  Aug 13, 2016 
PDF Page 164
Example 7-31

Page 31 recommends not using short open tags: <?=, but they are used in Example 7-31.

Rsil  Nov 27, 2015 
Printed Page 191
Example 9-2, line 9

if (date('H' >= 12)) {

should be

if (date('H') >= 12) {

Tristan Linnenbank  Dec 13, 2016 
Printed Page 192
Example 9-3, line 9

Same error as in example 9-2. Probably copy/paste?

Tristan Linnenbank  Dec 13, 2016 
Printed Page 198
Note

Regarding PHPExcel:

PHPExcel last version, 1.8.1, was released in 2015. The project is abandoned, no longer maintained, and should not be used anymore.

All users should migrate to its direct successor PhpSpreadsheet, or another alternative.


Jim Kovacs  Jan 30, 2018 
Printed Page 202
Example 9-20, line 8

Same error as on page 191 and 192. Probably copy/paste error

Tristan Linnenbank  Dec 14, 2016 
Printed Page 223
Last paragraph, 2nd line

When this happens, tge process_form()

should be

When this happens, the process_form()

Tristan Linnenbank  Dec 15, 2016