I am trying to learn oop in php, but the below code is not working could someone provide an alternate answer?
<?php
class abc {
public $a = 1;
$b = $a;
function foo(){
//some function..
}
}
?>
I want to assign value of variable “a” to variable “b”.
You can assign the value of
$ato$blike so:$this->b = $this->awithin the__constructmethod which gets called upon object creation, assuming you’re running PHP 5.