Trancemission
Technical User
I have a problem which is driving me mad and need some direction. I am trying to use my own functions. I have the following test code which I fail to get working on the following configs:
Apache + Php [4.3,4.2]
IIS + Php [4.3]
<?
function add($num1, $num2, $result=0)
{
$result = $num1 + $num2;
echo $result; <------ THIS WORKS!
return $result;
}
add(1,2);
echo $result;
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
echo "<P>$result</P>";
?>
</body>
</html>
Surley this is simple code and should work? And I totally missing the point and do I need to rtfm? As you can see the $num2 + $num2 is working as it prints in the function.
I have tried not putting $result=0 in the function
Cheers
Trancemission
=============
If it's logical, it'll work!
Apache + Php [4.3,4.2]
IIS + Php [4.3]
<?
function add($num1, $num2, $result=0)
{
$result = $num1 + $num2;
echo $result; <------ THIS WORKS!
return $result;
}
add(1,2);
echo $result;
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
echo "<P>$result</P>";
?>
</body>
</html>
Surley this is simple code and should work? And I totally missing the point and do I need to rtfm? As you can see the $num2 + $num2 is working as it prints in the function.
I have tried not putting $result=0 in the function
Cheers
Trancemission
=============
If it's logical, it'll work!