Bug traced in Zend Certification guide for PHP5

|

Bug traced in Zend Certification guide for PHP5

Recently my friend purchased 'Zend PHP 5 Certification Study Guide Oct 2006' by by Davey

Shafik
with Ben Ramsey published by PHP Architect

I was preparing for certication and few interviews. During the interview for six figure

salary job, I lost the job because of the false/bug in the book but authenticated it as

right.

In page number 17 (PHP Basics 17) there was an explanation for increment operator.

What will the output?
For this in the book, it is said 1. The explanation in the book is as follows:

It’s important to note that the operand in an increment or decrement operation
has to be a variable—using an expression or a hard-coded scalar value will simply
cause the parser to throw an error. Also, the variable being incremented or decremented
will be converted to the appropriate numeric data type—thus, the following
code will return 1, because the string Test is first converted to the integer number 0,
and then incremented:

$a = ’Test’;
echo ++$a;

If this question asked in interviews or in certification do not answer as 1.

The original output will be 'Tesu'.

For Example:
$a = 'B';
echo ++$a; //---- the out put will be 'C'

The code snippet is tested in both PHP4 and PHP5.

But as per the explanation in this book the output should be 1.

Excute the code snippets and confirm the results rather than blindly following the book is

best.




Submitted by gsee on Mon, 2007-07-09 04:12.

In php interviews output of the code snippets are asked. The interviewers must be personally execute the code and confirm the output to ask in interviews.

If they study in some books and prepare the questions without practically testing, which may lead to wrong interview result.



Click here to Receive Updates From this Blog