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.

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

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