[thelist] New Thread

Ian Anderson ian at zstudio.co.uk
Tue Apr 25 19:23:22 CDT 2006


A Binesh wrote:
> Hi,
>   I am trying to create a new discussion thread. I am sending this email 
> from my hotmail account , and not sure if it is in HTML format or plain 
> text. Hope it does not cause any problems.

Well, that seemed to work pretty well.

And what is this thread to be about, exactly? It is somewhat traditional 
to put at least a vague hint into the subject line.

Some content related to web design is an optional extra, too...

Cheers

Ian


<tip type="occasional php" author="Ian Anderson"
If you dabble in a little PHP from time to time, you'll be plagued by 
unexpected and unfriendly errors similar to this:

"Parse error: parse error, unexpected T_ECHO in 
/your/directory/path/foo.php on line 4"

There are two reasons for simple parse and/or runtime errors:
1. You missed a semicolon off the end of a line
2. You forgot the $ before some variable name

In JavaScript, you can usually get away without ending lines using a 
semicolon - ";". Ditto in ActionScript, because in both cases the 
carriage return is interpreted as the end of the statement. Not in PHP, 
though. Unlike these similar C-style languages, PHP allows lines of code 
to span multiple lines, but to do this it requires a semicolon 
terminating each statement that does not end a statement block.

This will break:

<?php
$foo = "wizzle"
echo $foo
?>

...because PHP sees it as:

<?php $foo = "wizzle"echo $foo ?>

This will be fine:

<?php
$foo = "wizzle";
echo $foo
?>

Put the semicolons and the "$" signs in first time round and you'll 
spend less time looking at the world's least intuitive error messages, 
and more time building Web 2.0...
</tip>


-- 
zStudio - Web development and accessibility
- http://zStudio.co.uk
Snippetz.net - Your personal, private code library
- http://snippetz.net




More information about the thelist mailing list