Posted by Rik on 10/01/95 11:56
T. Wintershoven wrote:
> English version:
>
> When i want to address a method in an object from a method that is
> within another object i get an error message that sais that the
> object doesn't exist.
It's a scope issue.
> The code below doesn't work because i use a function.
> require_once("clsTestObject.php");
> $objTestObject = new clsTestObject;
>
> do_test_var();
>
> function do_test_var()
> {
You either need:
global $objTestObject;
> $objTestObject->ShowTestVar();
> $objTestObject->SetTestVar();
> $objTestObject->ShowTestVar();
OR:
$GLOBALS['objTestObject']->ShowTestVar();
$GLOBALS['objTestObject']->SetTestVar();
$GLOBALS['objTestObject']->ShowTestVar();
> }
Check: http://nl3.php.net/manual/en/language.variables.scope.php
> Bij voorbaat dank
Graag gedaan,
--
Rik Wasmus
Navigation:
[Reply to this message]
|