How to access function inside PHP OOP
Posted
by Industrial
on Stack Overflow
See other posts from Stack Overflow
or by Industrial
Published on 2010-05-23T18:03:32Z
Indexed on
2010/05/23
18:11 UTC
Read the original article
Hit count: 153
Hi everyone,
What do I need to do to call $this->two() from inside my function innerOne? Is that possible with PHP OOP?
Here's the error I am recieving:
Fatal error: Using $this when not in object context
Here's how my code looks:
class myClass {
function one(){
function innerOne() {
// Some code
$this->two($var1, $var2);
}
// Some code
innerOne();
}
function two($var1, $var2) {
// Does magic with passed variables
return $var1 . $var2;
}
}
Thanks a lot!
© Stack Overflow or respective owner