Errata

Learning PHP 5

Errata for Learning PHP 5

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
Printed Page 29
2nd paragraph (11/04)

Example 2-17
print "
"; // this prints a linebreak

It does print a linebreak in the source html code but not on the web page. Needed:

print "<br />"; // this prints a linebreak

Anonymous   
Printed Page 29
2nd paragraph (11/04)

Example 2-17
print "\n"; // this prints a linebreak

It does print a linebreak in the source html code but not on the web page. Needed:

print "<br />"; // this prints a linebreak

Anonymous  Jun 23, 2008 
Printed Page 104
Example 6-26

Immediately after the line reading "print '<select name="sweet">'," the comment states that "$val is the option value, $choice is what's displayed"... but in the next line of code, these variables are written as $option and $label, respectively:

// $val is the option value, $choice is what's displayed
"foreach($sweets as $option => $label") ...

Clayton Thomas  Jul 27, 2009 
Printed Page 105
Example 6-28 code listing

There is a repeated omission of the closing single quote following print() statements. The first call to print() in this example lacks a closing quote, as does the 4th, 7th, and 10th.

The lines look like this:
print '<input type="checkbox" name="delivery" value="yes";

Note the missing single quote at the end of the statement; this results in a parse error.

Clayton  Jul 27, 2009 
Printed, Other Digital Version Page 106
Example 6-29

<pre>
Suppres "Undefine index ..." error messages if your php.ini config include E_NOTICE/E_ALL level errors

****
//print a radio button or checkbox
if($element_value == $values[$element_name]) {//...
SHOULD READ:
if(isset($values[$element_name]) && $element_value == $values[$element_name]) {//...

****
//print a <select> menu
//...
// print out the <option> tags
if($selected_options[$option]) {//...
SHOULD READ:
if(isset($selected_options[$option])) {//...

****
For the input name and Ttextarea just initiate default values on $defaults array:
$defaults = array('delivery' => 'yes',
'size' => 'medium');
SHOULD READ:
$defaults = array('name'=>' some value here...',
'delivery'=>'yes',
'size'=>'medium',
'comments'=>' some value here...'));
</pre>

Nick Tetcu  Jun 23, 2010 
Printed Page 162
show_form(), bottom of page

if ($errors) {
print '<ul><li>';
print implode('</li><li>',$errors)
print '</li></ul>'
}



This section returns an implode usage error. I corrected this by changing to this:

if ($errors != " ")

since the function statement initially defines
$errors = ' '

Pete Travis  Sep 20, 2009