Re: Function declaration failing on return value
| From: | Matthew Sims | Date: | Mon, 04 Oct 2004 21:43:59 +0000 |
| Subject: | Re: Function declaration failing on return value | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198621@lists.php.net to get a copy of this message | ||
> Don't get too excited; this is an awfully lame newbie question.
Too late, I'm already excited.
>
> 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
> --
> Whil
>
function square($num) {
$result = $num * $num;
return $result;
}
--
--Matthew Sims
--<http://killermookie.org>