baffled - please explain
| From: | Malcolm Mill | Date: | Fri, 10 Dec 2004 00:05:38 +0000 |
| Subject: | baffled - please explain | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203876@lists.php.net to get a copy of this message | ||
Hi,
I just came across a sniplet of code in a book I'm reading and I'm not
sure what point the author is trying to make.
The code is:
function my_function ( )
{
echo 'My function was called';
}
<?php
function my_function ( )
{
?>
My function was called
<?php
}
?>
What are those single opening and closing curly braces doing in
separate <?php ?> tag blocks? What's the point?
The author says "Withing a function, curly braces enclose the code
that performs the task you require. Between these braces, you can have
anything that is legal elsewheere in a PHP script" - PHP and MySQL Web
Development, 3rd Edition: Welling & Thomson.
If the point is to illustrate what this quote says, does that mean...
{
?>
My function was called
<?php
}
...is a syntactically correct code block for my_function?