Errata

Modern PHP

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
Mobi
Page Kindle Locations 7472-7476
In the TIP section aliases

Hello there,

In the TIP section of Appendix B, Kindle Locations 7472-7476, the author suggests the creation of an alias like this one :

I recommend you create command-line aliases for these Vagrant commands because you’ll type them a lot. Drop these into your ~/. bash_profile file and restart your terminal application:

alias vi =" vagrant init"

IMHO this is dangerous as it remaps a very common UNIX command: « vi »

Perhaps a solution to this would be to create the aliases as « vai » instead of « vi ». All other alias examples could also be changed like this :

alias vai =" vagrant init"
alias vau =" sudo echo 'Starting VM' && vagrant up"
alias vaup =" sudo echo 'Starting VM' && vagrant up --provision"
alias vap =" vagrant provision"
alias vah =" vagrant halt"
alias vas =" vagrant ssh"

That would prevent future issues for some people.

HTH,

David

Note from the Author or Editor:
Updated bash aliases.

David Robillard  Apr 23, 2015  Feb 26, 2016
PDF
Page 16
Example 2-10 descriptor

The descriptor of the example reads:
Example 2-10. StreamDocument class definition

It should read:
Example 2-10. CommandOutputDocument class definition

Note from the Author or Editor:
Fixed

Eric Blount  Mar 14, 2015  Feb 26, 2016
PDF
Page 24
4th paragraph

The line "However, generators greatly simply certain tasks while using less memory." should read "However, generators greatly simplify certain tasks while using less memory."

Note from the Author or Editor:
Fixed

imaguidhir  Sep 09, 2015  Feb 26, 2016
PDF
Page 32
2nd paragraph in Start the Server

"As you browse your application in your web browser, each HTTP
request is logged to standard out in your terminal application so you can see if you
application throws 400 or 500 responses."

should read:

"As you browse your application in your web browser, each HTTP
request is logged to standard output in your terminal application so you can see if your
application gives 400 or 500 responses."

Note from the Author or Editor:
Fixed

imaguidhir  Sep 09, 2015  Feb 26, 2016
PDF
Page 33
Last paragraph in "Router Scripts"

There's an extra 'a' in the last sentence of this paragraph.

"Using a router script is easy. Just pass the PHP script file path as a an argument when you start up the PHP built-in server:"

should read:

"Using a router script is easy. Just pass the PHP script file path as an argument when you start up the PHP built-in server:"

Note from the Author or Editor:
Fixed

imaguidhir  Sep 09, 2015  Feb 26, 2016
Printed
Page 90
Example 5-13, 5-14 and especially 5-15

The code in these examples is actually valid but confusing because you are inconsistent with regards to global namespace.

In 5-13 you do not preface `new DateTime` with a backslash but in 5-14 you use `new \DateTime`. And then in 5-15 you mix the two with sometimes prefix-ing with a backslash and sometimes without.

I understand that when you do not declare a namespace it's optional but it's still a bit messy. Being a bit picky though.

5-14 is also a bit confusing as you have a 3 as the third argument for DatePeriod but the outputs give 4 items. Only after reading page 92 did you introduce EXCLUDE_START_DATE.

That being said I am enjoying the book so far, so kudos!

Cheers,
Mike

Note from the Author or Editor:
Fixed.

Mike Reeves  Aug 10, 2015  Feb 26, 2016
Printed
Page 94
2nd paragraph, example 5-18

Example 5-18 description says that the database name is acme, username is josh and password is sekrit but the example DSN and parameters use books, USERNAME and PASSWORD respectively.

Note from the Author or Editor:
Fixed.

Elias Coronado  May 25, 2015  Feb 26, 2016
Printed
Page 95
1st paragraph

I recommend changing "Never hard-code database credentials into PHP files, especially PHP files served to the public" to "Never hard-code database credentials into PHP files served to the public". The right way IS to hard-code into PHP files, but not public ones (as is shown lower on the page).

Note from the Author or Editor:
Thanks. I have changed this particular text to instead recommend that developers remove credentials from code entirely and move them into environment variables. This way code remains portable.

Rick Silva  Nov 01, 2015  Feb 26, 2016
PDF, ePub, Mobi
Page 98
Example 5-22

the bindValue is used with string value and PDO::PARAM_INT data type.

$statement->bindValue(':email', $email, PDO::PARAM_INT);

Same error occurs in examples 5-22, 5-23, 5-24 and 5-25.

Note from the Author or Editor:
Fixed

harrijauri  Apr 10, 2015  Feb 26, 2016
Printed
Page 100
Example 5-25

Inside the while loop, the code tries to echo the 'name' property of the object stored in $result. The property should be 'email'.

Note from the Author or Editor:
Fixed

Anonymous  Mar 20, 2015  Feb 26, 2016
Printed
Page 102
Under // Withdraw funds from account 1 code section

$withDrawal should be $withdrawal in this line:
$stmtSubtract->bindParam(':amount', $withDrawal, PDO::PARAM_INT);

Nitpick: In this example money should be stored as a float and not as an integer. But seeing as there is no PDO::PARAM_FLOAT or PDO::PARAM_DOUBLE I see why you made it an int and punted instead of explaining.

Note from the Author or Editor:
Fixed

Mike Reeves  Aug 11, 2015  Feb 26, 2016
PDF
Page 138
2nd paragraph

The 2nd sentence of this paragraph reads: "The is the SSH server software’s configuration file". It should read "This is the SSH server software’s configuration file".

Note from the Author or Editor:
Changed to "The is the SSH server's configuration file..."

imaguidhir  Sep 16, 2015  Feb 26, 2016
Printed
Page 151
First note (2nd paragraph)

The benchmarking utility Siege was called "Seige".

Note from the Author or Editor:
Thanks! Found and corrected. It will be included in the next ebook updates and print edition.

Carsten Dietzel  Dec 17, 2015  Feb 26, 2016
PDF
Page 163
Roll Back Your Application

"In the off chance" should read "On the off chance".

Note from the Author or Editor:
Found and fixed.

imaguidhir  Sep 18, 2015  Feb 26, 2016
PDF
Page 166
"After" paragraph

"If you find a bug after your launch your application" should read "If you find a bug after you launch your application".

Note from the Author or Editor:
Found and fixed.

imaguidhir  Sep 18, 2015  Feb 26, 2016
PDF
Page 167
2nd paragraph of "Test-Driven Development (TDD)"

"This does not meant" should read "This does not mean".

Note from the Author or Editor:
Found and fixed.

imaguidhir  Sep 18, 2015  Feb 26, 2016
PDF
Page 171
1st paragraph

in this phrase,

The bootstrap.php file also specifies the path to our test suite (i.e., a directory that contains related test cases); ...

I think the 'bootstrap.php file' should be 'phpunit.xml file'. because bootstrap.php file doesn't contain any configuration about test suite. isn't it?

Note from the Author or Editor:
Fixed.

Anonymous  Aug 30, 2015  Feb 26, 2016
PDF
Page 174
1st paragraph, last sentence

"The second test that ensures the method throws an exception" should read "The second test ensures the method throws an exception".

Note from the Author or Editor:
Found and fixed.

imaguidhir  Sep 18, 2015  Feb 26, 2016
PDF
Page 197
2nd paragraph

The last word in this paragraph is misspelled. It should be "inference".

Note from the Author or Editor:
Found and fixed.

Ivan Maguidhir  Sep 18, 2015  Feb 26, 2016
Printed
Page 197
1st paragraph after code example

"The PHP interpreter enforces this expecation" should read "The PHP interpreter enforces this expectation".

Note from the Author or Editor:
Thanks! This is fixed and will be made available in the next print run.

Carsten Dietzel  Dec 22, 2015  Feb 26, 2016
PDF
Page 245
Last paragraph in "About the Author"

"You can at follow Josh on Twitter" should read "You can follow Josh on Twitter".

Note from the Author or Editor:
Found and fixed.

Ivan Maguidhir  Sep 19, 2015  Feb 26, 2016