Re: baffled - please explain

From: Date: Fri, 10 Dec 2004 00:15:25 +0000
Subject: Re: baffled - please explain
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203877@lists.php.net to get a copy of this message
Malcolm Mill wrote:
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

« previous php.general (#203877) next »