PHP in a Nutshell

Errata for PHP in a Nutshell

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 30
Case Switching

In the following code, there shouldn't be a space between the 2 equals signs - <?php $Name = "Bob"; if ($Name = = "Jim") { print "Your name is Jim "; } elseif ($Name = = "Linda") { print "Your name is Linda "; } elseif ($Name = = "Bob") { print "Your name is Bob "; } elseif ($Name = = "Sally") { print "Your name is Sally "; } else { print "I don't know your name! "; } ?> it should be: <?php $Name = "Bob"; if ($Name == "Jim") { print "Your name is Jim "; } elseif ($Name == "Linda") { print "Your name is Linda "; } elseif ($Name == "Bob") { print "Your name is Bob "; } elseif ($Name == "Sally") { print "Your name is Sally "; } else { print "I don't know your name! "; }

Anonymous   
Printed
Page 49
2nd to last paragraph in Escape Sequences section

should read: if you type 'Hello ', PHP will...

Anonymous   
Printed
Page 68
1st code sample

The comment in the following code sample is wrong $names = array ("Timmy", "Bobby", "Sam", "Tammy", "Joe" ); $firstname = array_pop($names); // first name is Timmy, last is Joe again The comment should read // first name is Timmy, last is now Tammy

Anonymous   
Printed
Page 69
The output for the array_shift() example

In the output of the example, it includes "Danny" - it should not.

Anonymous   
Printed
Page 83
First code sample

The fourth line print 12 + === 12; should read print 12 === 12;

Anonymous   
Printed
Page 83
5th paragraph

In the second example for the '===' operator, there are two if-statements and associated codeblocks, reproduced here: if (0 === false) { // this is true } if (0 === false) { // this is false } The first if-statement is incorrect; it should use the '==' operator instead of '==='. The correct example should read: if (0 == false) { // this is true } if (0 === false) { // this is false }

Anonymous   
Printed
Page 87
9th paragraph

As an example of operator associativity, the book uses the example of a make-believe operator 'mu' (the Greek letter). In the normal text (serif font), the symbol itself appears (i.e. it is not spelled out like I have done above). However, in the two following code examples (monospaced font, one at the bottom of page 87, the other at the top of page 88), the symbol does not appear; a space is printed instead. The examples appear like this in the text: $foo = $a $b $c; // would be treated as... $foo = ($a ($b $c)); $foo = $a $b $c; // would be treated as... $foo = (($a $b) $c); In each case, the symbol for 'mu' should (presumably) take the place of a space between two variables, or between a variable and a parenthesis.

Anonymous   
Printed
Page 92
asin() description

"essentially reversing the operation of sine()" should be "essentially reversing the operation of sin()"

Anonymous   
Printed
Page 93
bindec() description

"print decbin("10000"); // 16" should be "print bindec("10000"); // 16"

Anonymous   
Printed
Page 94
ceil() description

"nothing will happen" should be "the parameter will be returned unchanged"

Anonymous   
Printed
Page 94
connection_status() description

"2 if the connection has been aborted" should be "2 if the connection has timed out"

Anonymous   
Printed
Page 97
dechex() definition

The dechex() function converts a decimal number into a binary number. should be: The dechex() function converts a decimal number into a hexadecimal number.

Anonymous   
Printed
Page 102
htmlentities function

html_entities() should really be htmlentities()

Anonymous   
Printed
Page 102
hexdec() example

"print hexdec(e8); // 232" should be "print hexdec("e8"); // 232"

Anonymous   
Printed
Page 102
Function reference: html_entities()

html_entities() should be: htmlentities() thoughout the whole entry.

Anonymous   
Printed
Page 106
number_format() function, last example

echo "Total charge is $", number_format($total, 2, ".", ","), " Euros"; should be: echo "Total charge is $", number_format($total, 2, ",", "."), " Euros";

Anonymous   
Printed
Page 110
Table 7-2

"Parameter is a positive integer" should read "Parameter is an integer"

Anonymous   
Printed
Page 125
Final code example

Under the heading ucwords(), the final line of the example $a = strtoupper($string); should be: $a = ucwords($string);

Anonymous   
Printed
Page 125
ucfirst() description

"$a = strtoupper($string);" should be "$a = ucfirst($string);"

Anonymous   
Printed
Page 130
1st line of code sample

"class dog {" declaration should be "class Dog {". (Capital 'D')

Anonymous   
Printed
Page 146
Last text paragraph

The line: "However, if you use ==, you will get false back," should read: "However, if you use ===, you will get false back," The sentence is trying to point out the difference between == and ===, but it incorrectly uses ==.

Anonymous   
Printed
Page 186
Last line of sample code at top

The second </body> tag should be </html> instead.

Anonymous   
Printed
Page 188
First code example

In the first two echo commands, the closing anchor tag </A> should be: </a>.

Anonymous   
Printed
Page 196
Second paragraph under "file_get_contents() and file()" section

The first sentence reads: "The file_get_contents() function opens $varname..." It should read: "The file_get_contents() function opens $filename..."

Anonymous   
Printed
Page 237
Table 15-4

The fourth example down in Table 15-4. The result in the right hand coloumn states "True; must end with one lowercase letter", when it it should read "False; must end with one lowercase letter". This particular example is on the author's own website, where it shows the correct result: http://www.hudzilla.org/phpbook/read.php/4_8_3

Anonymous   
Printed
Page 240
Sub Section: Storing Matched Strings - second code example

Last line of code example reads: var_dump($myarray); Should read: var_dump($matches);

Anonymous   
Printed
Page 296
code & 2nd paragraph

Code example and text are inconsistent. The code example allows you to end the session with !halt or !close, but the text tells one to type !shutdown to end the session.

Anonymous   
Printed
Page 298
First paragraph

The first sentence reads "The headers_sent() takes no parameters,..." It should read "The headers_list() function takes no parameters,..."

Anonymous