View sourcecode

The following files exists in this folder. Click to view.

CHuman.php

1 lines ASCII Unix (LF)
1
<?php
/**
 * Class to represent humans.
 */
class CHuman {

    /** 
     * Properties
     */
    private $name;
    private $age;
    private $profession;


    /** 
     * Constructor
     */
    public function __construct($name, $age, $profession = "unemployed") {
        $this->name = $name;
        $this->age = $age;
        $this->profession = $profession;        
    }


    /** 
     * Destructor
     */
    public function __destruct() {
        echo "Destroying object: $this->name";
    }



    /**
     * Get a string representing the human.
     *
     * @param string $human      ...
     * @param string $age        ...
     * @param string $profession ...
     * 
     * @return string ... 
     */
    protected function description() {
        //global $name;
        return "My name is $this->name, I'm $this->age old and work as a $this->profession.";    
    }


    /**
     * Get a HTML string representing the human.
     *
     * @param string $human      ...
     * @param string $age        ...
     * @param string $profession ...
     * 
     * @return string ... 
     */
    public function descriptionAsHtml() {
        //global $name;
        return "<p>" . $this->description() . "</p>";    
    }
}