Jump to content

gilley

New Members
  • Posts

    4
  • Joined

  • Last visited

gilley's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I think this is pretty basic stuff for you but it is giving headache for me, hope you can help me. So I have this piece of code: <?php class example { //protected $a; //protected $c; public function NumberInput($number){ $this->a = $number; } public function NumberOutput(){ return $this->a; } } class example2 { public function __construct(){ $this->mergingclass = new example; } public function numberInput2($number){ $this->c = $number; } public function NumberOutput2(){ return $this->c; } public function __call($method,$arguments){ echo "called method is $method <br> "; return $this->x = $arguments; } } $b = new example2; $b->NumberInput(7); echo $b->NumberOutput(); ?> And here are things that are confusing me: 1) this code is working the same way when I delete __construct function , or atleast I don't notice the change. I have read manual about construct method but I still don't understand what does it do. 2) it doesn't echo number 7 when I execute it, but instead I get just "Array" written. Why is it storing number 7 in array ?. How can I echo just number 7 ? Thanks a lot in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.