Traits

The php trait is not supported until php ver 5.4. I'm still not there yet, running: Apache
trait tDebug {
    
    // Method dumps out a lot of data about the current object:
    public function dumpObject() {
        
        // Get the class name:
        $class = get_class($this);
        
        // Get the attributes:
        $attributes = get_object_vars($this);

        // Get the methods:
        $methods = get_class_methods($this);
        
        // Print a heading:
        echo "

Information about the $class object

"; // Print the attributes: echo '
Attributes
    '; // CEJ mod: If the attribute is an array - print the array foreach ($attributes as $k => $v) { if (is_array($v)) { echo '
    key is: '.$k;
    			print_r($v);
    			echo '
    '; } else { echo "
  • $k: $v
  • "; } }//end foreach echo '
'; // Print the methods: echo '
Methods
    '; foreach ($methods as $v) { echo "
  • $v
  • "; } echo '
'; } // End of dumpObject() method. } // End of tDebug trait.