Classes / Constructors

<?php

class Man {
    public $name = "";
    public $country = "unknown";

    //You cannot overload PHP functions
    function __construct()
    {
        $a = func_get_args();
        $i = func_num_args();
        if (method_exists($this,$f='__construct'.$i)) {
            call_user_func_array(array($this,$f),$a);
        }
    }

    function __construct1(string $name) {
        $this->name = $name;
    }

    function __construct2(string $name, string $country) {
        $this->__construct1($name);
        $this->country = $country;
    }
}

$man = new Man("Vladimir""Russia");

echo $man->name"\n", $man->country;