Reply to Re: [PHP] passing return value from fucntion

Your name:

Reply:


Posted by William Stokes on 03/18/05 10:43

Never mind I got it figured out. Had to set a global variable to make it
visible.
Thanks anyway

-Will

"Forest Liu" <oxware@gmail.com> kirjoitti
viestissδ:2f640a570503180005238eaa45@mail.gmail.com...
I donot understand your problem clearly yet.
I think there must be a caller and a callee (called function) when we
talking about "passing arguments". That is to say, you write in your
main program:

....
echo calc($rs)."<br>";
....

and make sure there is a function named "calc":

function calc($rightsid){
....
if(...){
} elseif ($rightsid == $oik6) {
$res = ok;
return $res;
} elseif ($rightsid == $oik7) {
$res = notok;
return $res;
}
....
}

then the result calculated in the function would be passed to the
point you calling in your main program.

Certainly,"ok" and "notok", I think they should be boolean, as "true"
and "false". If you really write your code like that exactly, the two
words "ok" and "notok" wont have any effective meaning.

wish it helps to you.

On Fri, 18 Mar 2005 09:33:13 +0200, William Stokes <kalles@operamail.com>
wrote:
> Hello,
> Just simple question (I think?)
>
> How to pass return value from function to the main program?
>
> Here's example:
> do some code in funtion to set the $res value:
>
> } elseif ($rightsid == $oik6) {
> $res = ok;
> return $res;
> } elseif ($rightsid == $oik7) {
> $res = notok;
> return $res;
> }
>
> How can I get to use the $res in the main program. The return $res;
> doesn't
> pass the variable to the main program right?
>
> Thanks
> -Will
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Sincerely,
Forest Liu(???)

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация