View Review Details
| Book: |
|
Programming PHP |
| Subject: |
|
A comment about the style |
| Date: |
|
2008-04-28 23:08:00 |
| From: |
|
Doug Lerner
|
|
|
I am still just reading it. It seems like a useful book, but not as comprehensive, orderly and error-free as my O'Reilly "JavaScript" book is. Maybe the language itself is not as orderly. But it seems there are a lot of language notations that are used before being defined in a later chapter.
I am still working my way through it and may come back and increase my rating of it later on (if possible), but for now I wanted to just mention one really annoying style matter that makes the code samples hard to read (and is the reason I decided to pause and write a review).
This is a typic code sample (I bought the PDF version of the book):
function update_counter () {
static $counter = 0;
$counter++;
echo "Static counter is now $counter\n";
}
$counter = 10;
update_counter();
update_counter();
echo "Global counter is $counter\n";
Static counter is now 1
Static counter is now 2
Global counter is 10
The last three lines are the result of running the code above it. Could that not be distinguished somehow? Could there not be a separator between the code and the results? Or could not a different type style be used? Or even add a line break and say "This results in:" or something like that?
All the samples run the code and results together which make them difficult to read. I was surprised a format like that would be used.
doug
|
"...the best coverage of the core language Ive ever read. Buy the book."
--Stefan Mischook, KillerPHP.com
-
Re: A comment about the style, November 17 2008
Submitted by
cambridge
[Respond | View]
its simple only create a typical php file and then you see that the code sample is a simple code:
< ?
function update_counter () {
static $counter = 0;
$counter++;
echo "Static counter is now $counter\n";
}
$counter = 10;
update_counter();
update_counter();
echo "Global counter is $counter\n";
? >
This results in
you will see the output:
Static counter is now 1
Static counter is now 2
Global counter is 10
The simple code expect the knowledge of the simpliest way of computing: code and output
The fully simple knowledge is: input - code - output