|
Posted by Rik on 10/17/16 11:49
emrahayanoglu@gmail.com wrote:
> i tried like other languages. This is an example.
> PHP5
>
> class emr
> {
> function __construct($username)
> {
> }
> function __construct($username, $password)
> {
> }
> function __construct($username, $password, $name)
> {
> }
> }
If that's what you wnat, why not declare some defaults for the variables:
function __construct($username, $password=false, $name=false)
{
if($name!==false)//execute some code
if($password!==false)//domething else
}
Etc.
Which makes you able to:
$a = new emr('username');
And all arguments left out will result in their default values.
Else, it's up to the earlier mentioned func_get_args();
Grtz,
--
Rik Wasmus
[Back to original message]
|