Function declaration failing on return value

From: Date: Mon, 04 Oct 2004 20:59:01 +0000
Subject: Function declaration failing on return value
Groups: php.general 
Request: Send a blank email to php-general+get-198620@lists.php.net to get a copy of this message
Don't get too excited; this is an awfully lame newbie question. I'm trying out my first functions and can't get past some sort of stupid syntax mistake I'm making. I've cut the following snippet directly out of the online PHP manual and put it in a PH page, like so: <html> <head><title>Test function</title></head> <body > <b>Square of number/b></font><br><br> <?php function square($num) { return $num * $num; } echo square(4); // outputs '16'. ?> <br> </body> </html> When I run the php page, I get Parse error: parse error, unexpected T_RETURN in /var/www/html/afi/sq.php on line 12 I've experimented with a half dozen different functions and variations, and I'm always getting the same 'unexpected T_RETURN' error. This is pretty basic but I'm outa clues. I've searched the archives for the last 3 mo for T_RETURN (and user-defined functions) as well as the online doc; no relevant hits. Thanks, -- Whil Moving to Linux: Freedom, Choice, Security, Opportunity http://www.hentzenwerke.com

« previous php.general (#198620) next »