PHP Classes

File: classinfo.b1.readme.txt

Recommend this page to a friend!
  Classes of Ariel Filipiak   Classinfo class   classinfo.b1.readme.txt   Download  
File: classinfo.b1.readme.txt
Role: ???
Content type: text/plain
Description: Instructions to use and Options
Class: Classinfo class
Like phpinfo() but for ALL your classes!!!
Author: By
Last change:
Date: 21 years ago
Size: 3,896 bytes
 

Contents

Class file image Download
------------------------------------------------------------------------------------ CLASSINFO CLASS v.b1 ------------------------------------------------------------------------------------ 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. If you are a developer and share your classes you can add this few lines too. If someone try to use and don't have the classinfo class the functions return: classInfo class not found!!! (You can download it from www.phpclasses.org) ------------------------------------------------------------------------------------ ADDING A FEW LINES IN YOUR CLASSES ------------------------------------------------------------------------------------ Is very simple. You can see the example: classinfo.b1.example.php 1.- At the end of the list of vars defined you nedd add this lines: a| /* This is for ClassInfo Class. */ b| var $class_version = "example v.3 by Anonymous"; c| var $class_vars = array("var1", "var2", "var3"); d| var $class_location = __FILE__; e| var $class_constructor; | f| function classinfo($b_noshow = "") { g| $s_check_class = (function_exists(class_exists) ? class_exists : function_exists); h| 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; i| $o_classinfo = new classinfo($this->class_version, $this->class_location, $this->class_constructor); j| for ($i = 0; $i < count($this->class_vars); $i++): $o_classinfo->vars[$this->class_vars[$i]] = $this->{$this->class_vars[$i]}; endfor; k| $o_classinfo->info($b_noshow); l| } m| /* End of info & function for ClassInfo Class. */ b.- You must put the name of the class, version, author... all you want. c.- Array of the name of the vars of your class (only) whose state you want listed in info. d-l.- These shouldn't need modifications a,m.- Just comments. 2.- If your class have a constructor function you add this line $this->class_constructor = "example(\"$var1\", \"$var2\")"; // This is info for ClassInfo Class. Where "example" is the name of the function constructor and "$var1", "$var2" are the parameters. ------------------------------------------------------------------------------------ USING CLASSINFO ------------------------------------------------------------------------------------ See the example working: classinfo.b1.example.php When you have an object of a class you can get: 1.- class_constructor echo $object->class_constructor -> Print the constructor with parameters. 2.- class_version echo $object->class_version -> Print the class name, version, info, etc. 3.- class_location echo $object->class_location -> Print the location of the class. 4.- classinfo() $object->classinfo(["noshow"]); Print a table with, class_constructor, class_version, class_location, last modified of the file whose contain the class, and the value of the variables listed in the class_vars array. The las line have the version and location of the classinfo class. If you add "noshow" this table is printed like a comment and you should need see the source code of your page to see it. If you don't want the list of variables use: $object->class_vars = ""; $object->classinfo(["noshow"]); and if you want just the first variable value use: $object->class_vars = array("var1"); $object->classinfo(["noshow"]);