Hi Guys,

Given below is a PHP script. Can someone help me with the output of the
code. According to my understanding the output should be 3, 50, 20, 10. Can
someone elaborate on the same and provide me an explanation on the flow?

Thanks a lot in advance.

class TestClass {
var $a =20;
var $b =10;
function TestClass($a= null, $b=null) {
 if (!is_null($a))
   $this-­‐>a= $a;

function printAB() {
echo $this-­‐>a.” “.$this-­‐>b.”\n”;

$inst1 = new TestClass(3,50);
$inst2 = new TestClass();

Reply via email to