[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    [PHP-DB] Flow of PHP testClass
From:       Rikin Parekh <rikin08 () gmail ! com>
Date:       2012-03-29 14:57:07
Message-ID: CALbBjteqg0Cqs=Pjk9wpb=h7vo36H7fUooXVMJPOWSuGNu544Q () mail ! gmail ! com
[Download RAW message or body]


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.

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

function printAB() {
echo $this- ­->a." ".$this- ­->b."\n";
 }
}

$inst1 = new TestClass(3,50);
$inst2 = new TestClass();
$inst1- ­->printAB();
$inst2- ­->printAB();
?>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic