PHP Reference Book Blog

PHP Reference: Beginner to Intermediate PHP5

Archive for the ‘Corrections’ Category

Dec-21-09

fwrite() has a Double Tip that is Misplaced

posted by Mario Lurig

On page 131, the fwrite() function has a TIP that reads:
 
To read the entire file into a string, use the function filesize().

// file.txt contains the sentence: Hello World!
$filename = 'file.txt';
$file = fopen($filename, 'r');
$string = fread( $file, filesize($filename) );
var_dump($string);
// file.txt now contains at the end: Hello World!

You’ll notice that this is the same tip as fread() and doesn’t belong. It should be considered ‘removed’.

Dec-20-09

Index: array_combine() array_key_exists()

posted by Mario Lurig

Some quick corrections for the Function Index:

pg. 162

preg_match_all: 157-158

pg. 161

array_combine: 73
array_key_exists: 79-80

Feb-2-09

array_key_exists() Function Index Correction

posted by Mario Lurig

Thanks to John for submitting this correction!

In the Function Index (pg. 161), array_key_exists() is listed as page 82. However, it is actually on page 79.

Feel free to submit a correction yourself if you find any!

Jan-13-09

Print_r optional parameter correction

posted by Mario Lurig

(pg. 38)

In the book, the print_r() function is described as follows:

print_r($variable)

Output the contents of $variable . Typically used to display the contents of an array.

However, there is also an optional flag for the print_r() function that makes the function return the output rather than printing it to the screen. Therefore, the section of the book should be amended as follows:

print_r($variable [,return])

return – [optional] $boolean default: FALSE, print output
Output the contents of $variable. Typically used to display the contents of an array. If return is set to TRUE, print_r() returns the output rather than displaying it, such as when storing it in a variable.

Tags:
Jan-1-09

mysql_result() correction

posted by Mario Lurig

(pg. 123)

The function has the following correct syntax:

mysql_result(resource, row[, column])

However, in the explanation paragraph, 2nd sentence, it uses the term field erroneously instead of the term column. It should read as follows:

If column is specified instead of the value of the
first column, the specified column is retrieved (can be referenced by number
starting with 0 or by name/alias).

It’s the little things, like changing the term used to be clearer to the reader and forgetting to update everything.