|
-
March 29th, 2009, 10:29 PM
#1
Cannot pass a passed in variable to a function? [PHP5]
I've run into a little problem, chances are the solution is simple but I've yet to uncover the work-around.
I'm trying to take a passed in parameter and pass it into a another function, but it comes out as being null, for example:
The following works fine:
Code:
public function get($ID)
{
$myA = new A();
return $myA->foo(1);
}
I can see that in foo() the value passed in is '1' as expected (obviously).
However when I try the following it seems to fail:
Code:
public function get($ID)
{
$myA = new A();
return $myA->foo($ID);
}
The difference is that I am passing in $id from get($ID) into foo($ID) - why doesn't this work?
The parameter in foo($ID) comes out as being NULL (unless I am not seeing this right).
Do I need to do like $temp = $ID and pass foo($temp) instead?
Any help would be much appreciated.
Thanks,
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
|