Here is an example of what I'm trying to achieve:
class Employee {
private $empno;
private $ename;
private $job;
private $mgr;
private $hiredate;
private $sal;
private $comm;
private $deptno;
function __construct($empno = 100, $ename = "Default E Name",
$job = "nothing", $mgr = null, $hiredate = "1970-01-01",
$sal = 0, $comm = 0, $deptno = 0) {
$this->empno = $empno;
$this->ename = $ename;
$this->job = $job;
$this->mgr = $mgr;
$this->hiredate = $hiredate;
$this->sal = $sal;
$this->comm = $comm;
$this->deptno = $deptno;
}
}
I want to create an object this way:
$employee = new Employee($e_number, $e_name, $e_function,
DEFAULT, $e_date, $e_salaire, DEFAULT, $e_dept);
// Where 'DEFAULT' is used to specify that the default value of the argument shall be used
How can I explicitly tell the constructor of a class
that I want the default value to be used ?
I know that for the example, in C++, you should leave the arguments with default values to the end of the function's signature, but I don't know if it's the same case for PHP too.