« Back to the index
\core\WADebug example
";
echo "DomCore version ".\core\WADebug::VERSION."
";
echo "HTML API ? ".(\core\WADebug::getHTMLAPI()?'Yes':'No')."
";
echo "OS Type ? ".(\core\WADebug::getOSType()==\core\WADebug::WINDOWS?'Windows':(\core\WADebug::getOSType()==\core\WADebug::UNIX?'Unix':'Mac'))."
";
echo "
";
// We fix the output on screen in HTML
\core\WADebug::setRedirect(\core\WADebug::HTMLREDIR, null);
// We fix the output to SYSTEM level (all the messages)
\core\WADebug::setLevel(\core\WADebug::SYSTEM);
// We start debug mode
\core\WADebug::setDebug(true);
class A extends \core\WADebug
{
public $a = 1;
function __construct()
{
// ALWAYS CALL THE CONSTRUCTOR OF THE FATHER
parent::__construct();
// WE RECOMMEND ALWAYS FILTER THE CALL TO DODEBUG (MUCH FASTER)
if (self::$debug || $this->localdebug)
$this->doDebug("Constructor of A class", \core\WADebug::SYSTEM);
}
public function setA($newvalue)
{
if (self::$debug || $this->localdebug)
$this->doDebug("We set new value to A->a : %.", \core\WADebug::INFO, $newvalue);
$this->a = $newvalue;
}
}
class B extends A
{
public $b = 5;
function __construct()
{
parent::__construct();
if (self::$debug || $this->localdebug)
$this->doDebug("Constructor of B class", \core\WADebug::SYSTEM);
}
public function setB($newvalue)
{
if (self::$debug || $this->localdebug)
$this->doDebug("We set new value to B->b: %.", \core\WADebug::INFO, $newvalue);
$this->b = $newvalue;
}
}
// We create new instances
$instance1 = new A();
$instance2 = new A();
$instance3 = new B();
// We assign new values
$instance1->setA(10);
$instance2->setA(20);
$instance3->setA(30);
$instance3->setB(40);
// We show the instances data
print $instance1->explain();
print $instance2->explain();
print $instance3->explain();
// We show A and B data
print 'Qt of instances of A: '.$instance1->getNumInstances() . "
";
print 'UID of first A: '.$instance1->getUIDInstance() . "
";
print 'Qt of instances of B: '.$instance3->getNumInstances() . "
";
print 'UID of B: '.$instance3->getUIDInstance() . "
";
// We show global debug data
print 'Total quantity of instances: '.\core\WADebug::getNumTotalInstances() . "
";
// We terminate debug session
\core\WADebug::setDebug(false);
?>
« Back to the index