PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi Experts ,
I have a problem .below is code.......
class A{
var $defined="This is defined";
var $undefined="This is undefine";
function foo(){
if(isset($this)){
print $this->defined;
}
else print $this->undefined;
}
}
class B extends A{
function bar(){
A::foo();
$this->defined.="From Class B";
$this->undefined.="From Class B";
}
}
$a=new A();
$a->foo();
A::foo();
$b=new B();
$b->bar();
B::bar();
?>
so in class B i want to concat the string "From Class B" in the variables $defined ,and $undefined ,but giving errors.
please solve it or Suggest a solution to alter the variables....
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
This is defined
Notice: Undefined variable: this in C:\Program Files\Apache Group\Apache2\htdocs\testclasses.php on line 10
This is defined
Notice: Undefined variable: this in C:\Program Files\Apache Group\Apache2\htdocs\testclasses.php on line 10
Notice: Undefined variable: this in C:\Program Files\Apache Group\Apache2\htdocs\testclasses.php on line 16
Notice: Undefined property: defined in C:\Program Files\Apache Group\Apache2\htdocs\testclasses.php on line 16
Notice: Undefined property: undefined in C:\Program Files\Apache Group\Apache2\htdocs\testclasses.php on line 17
This is what this code returns with error_reporting(E_ALL) on php 4.4.1
I don't see any errors...but trully I don't like this notices