To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
On 10 December 2004 00:06, 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 point is you can put raw HTML (or anything else!) in there which can be extremely useful for very long chunks, or blocks containing lots of quotes. I think that example could have been better constructed to illustrate this point; something like: function my_function ( ) { echo "<p class=\"interesting\">\n" echo " My <a href=\"function_source.php\">function</a> was called\n" echo "</p>\n"; } <?php function my_function ( ) { ?> <p class="interesting"> My <a href="function_source.php">function</a> was called </p> <?php } ?> > 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? Yes. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php