Login   Register  
PHP Classes
elePHPant
Icontem

File: classinfo.b1.example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ariel Filipiak  >  Classinfo class  >  classinfo.b1.example.php  >  Download  
File: classinfo.b1.example.php
Role: ???
Content type: text/plain
Description: Example
Class: Classinfo class
Like phpinfo() but for ALL your classes!!!
Author: By
Last change:
Date: 12 years ago
Size: 2,297 bytes
 

Contents

Class file image Download
<?php
include("./classinfo.b1.class.php");

class example {

    var $var1;
    var $var2;
    var $var3;

    /* This is for ClassInfo Class. */
    var $class_version  = "example v.3 by Anonymous";
    var $class_vars     = array("var1", "var2", "var3");
    var $class_location = __FILE__;
    var $class_constructor;

    function classinfo($b_noshow = "") {
        $s_check_class = (function_exists(class_exists) ? class_exists : function_exists);
        if (!$s_check_class('classinfo')): echo ($b_noshow ? "\n<!--\n\n" : "<br><b>")."classinfo class not found!!! (You can download it from www.phpclasses.org)".($b_noshow ? "\n\n-->\n" : "</b><br>"); return; endif;
        $o_classinfo = new classinfo($this->class_version, $this->class_location, $this->class_constructor);
        for ($i = 0; $i < count($this->class_vars); $i++): $o_classinfo->vars[$this->class_vars[$i]] = $this->{$this->class_vars[$i]}; endfor;
        $o_classinfo->info($b_noshow);
    }
    /* End of info & function for ClassInfo Class. */
    
    function example($var1, $var2) {

        $this->class_constructor = "example(\"$var1\", \"$var2\")"; // This is info for ClassInfo Class.
        $this->var1 = $var1;
        $this->var2 = $var2;
        $this->var3 = array($var1, $var2);
    }
    
    function test() {
        return $this->var1 + $this->var2;
    }
}

echo "<font face='Arial' size='2'>";
echo "<H2>classinfo</H2>";
echo "When you work with objects and classes, just a few lines in every class you use can help you to see information about the class and the current state of an object includes variables values.<hr size=1>";

$test = new example(2, 4);
echo "<b>echo \$test->test()</b> print <b>".$test->test()."</b><br>";
echo "<b>echo \$test->class_constructor</b> print <b>".$test->class_constructor."</b><br>";
echo "<b>echo \$test->class_version</b> print <b>".$test->class_version."</b><br>";
echo "<b>echo \$test->class_location</b> print <b>".$test->class_location."</b><br>";
echo "<b>\$test->classinfo()</b> print next table (The style change if you use php3 or php4)<br>";
echo "<b>\$test->classinfo(\"noshow\")</b> print data as comment (see the source code of this page)<br>";
$test->classinfo();
$test->classinfo("noshow");

?>