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?
It is correct but it is not suggested.
The author want to show to you instead of using echo 'My function was called', you can do in that way.
but { ?> My function was called <?php }
is not correct :)
best regards adwin www.kuya-kuya.net www.e-rhema.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php