|
-
Sep 18th, 2005, 10:36 PM
#1
Thread Starter
PowerPoster
function return value
Is it possible in php to return a value from a function?
eg. In VB it would be written like the below which would return True or False.
VB Code:
Function MyFunction() as Boolean
'do whatever inside function
'MyFunction = True
'or
'MyFunction = False
Last edited by lintz; Sep 18th, 2005 at 11:34 PM.
-
Sep 18th, 2005, 10:42 PM
#2
Lively Member
Re: function return value
Yep it is:
PHP Code:
<?php
function myFunc()
{
$foo = "yakbar";
if($foo == "foobar")
{
return $foo;
}
else
{
return false;
}
}
echo myFunc();
?>
-
Sep 18th, 2005, 10:44 PM
#3
Thread Starter
PowerPoster
Re: function return value
Thanks {yak}. I knew there must have been a way 
So would the below code work?
PHP Code:
if (MyFunction() == "True") {
//Do this because the function returned True
}
else {
//Do this because the function returned False
}
EDIT: I played around with it and it does work.
Last edited by lintz; Sep 18th, 2005 at 11:36 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|