Re: Function declaration failing on return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux