visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
304 experts, 1182 registered users, 1626 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Languages :: PHP :: make a function to read the value from another function


By: rac2000 U.S.A.  Date: 05/10/2003 00:00:00  English French  Points: 50 Status: Answered
Quality : Excellent
i need to make a function to read the result from another function. what i did is an example with the calculation of a+b. what i whant to do is to be able to echo the value of a+b with the function main.
where is the mistake?

function main()
{


a=5
b=10

calcul (a,b)


return val
}


function calcul(a.b)
{
a+b
return val
}



By: rac2000 Date: 05/10/2003 16:24:00 English  Type : Comment
Can I make a class of functions ant to link them somehow?
By: VGR Date: 06/10/2003 05:02:00 English French  Type : Comment
c'ets simple : il manque les instructions genre print ou echo ;-))

function main()
{


$a=5
$b=10

$val=calcul ($a,$b);


return $val;
}


function calcul($a.$b) {
$res=$a+$b;
return ($res);
}

By: VGR Date: 06/10/2003 05:03:00 English French  Type : Answer
to print :

echo "le résultat est $val
";

dans main.php après l'affectation de $val=calcul($a,$b);
By: rac2000 Date: 06/10/2003 05:42:00 English  Type : Comment
as you can see i had the concept write. maybe i made some mistakes in the variables names. i have no ideea why it wasn't working.
you had a litle mistake in your code to. in the calcul you put a dot insted of comma . here is the working code :

<?

function main($a,$b)
{
$val=calcul($a,$b);
return $val;
}

function calcul($a,$b) {
$res=$a+$b;
return $res;
}

$x=main(5,5);
echo "le résultat est $x
";


?>

thanks.

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 43.964150 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page