Welcome Guest, Not a member yet? Register   Sign In
Newbie: Fatal error: Using $this when not in object context - URI Helper.
#3

[eluser]GSV Sleeper Service[/eluser]
because vars within functions are not global, unless you use the 'global' keyword.
eg
Code:
$foo = 'donkey';
function bar(){ return $foo; }
function bar2(){ global $foo; return $foo; }
echo bar(); //will produce an error
echo bar2(); //will echo 'donkey'
if you want to use $this in a function then you'll have to either make it global (bad!) or pass in a reference to $this as a parameter to your function. have a good think about what you're doing, I'm sure there's a cleaner solution.


Messages In This Thread
Newbie: Fatal error: Using $this when not in object context - URI Helper. - by El Forum - 09-08-2009, 09:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB