Skip to main content

is it possible set method variable default value if variable is expected to be "new class"

class controller{ function getData(client $client){ } } $c = new controller; $c->getData( new client );   TO SET DEFAULT VALUE LIKE 

TO SET DEFAULT VALUE LIKE

class controller{ function getData(client $client = new client){ } } $c = new controller; $c->getData(); 

is it possible set method variable default value if variable is expected to be "new class"

class controller{ function getData(client $client){ } } $c = new controller; $c->getData( new client );   TO SET DEFAULT VALUE LIKE class controller{ function getData(client $client = new client){ } } $c = new controller; $c->getData(); 

is it possible set method variable default value if variable is expected to be "new class"

class controller{ function getData(client $client){ } } $c = new controller; $c->getData( new client ); 

TO SET DEFAULT VALUE LIKE

class controller{ function getData(client $client = new client){ } } $c = new controller; $c->getData(); 
added 76 characters in body
Source Link
chris85
  • 23.9k
  • 7
  • 36
  • 51

is it possible set method variable default value if variable is expected to be "new class"

class controller{

class controller{ function getData(client $client){  } 

}

$c = new controller; $c->getData( new client );

TO SET DEFAULT VALUE LIKE

class controller{

} $c = new controller; $c->getData( new client ); TO SET DEFAULT VALUE LIKE class controller{ function getData(client $client = new client){ } } $c = new controller; $c->getData(); 

}

$c = new controller; $c->getData();

is it possible set method variable default value if variable is expected to be "new class"

class controller{

function getData(client $client){ } 

}

$c = new controller; $c->getData( new client );

TO SET DEFAULT VALUE LIKE

class controller{

function getData(client $client = new client){ } 

}

$c = new controller; $c->getData();

is it possible set method variable default value if variable is expected to be "new class"

class controller{ function getData(client $client){  } } $c = new controller; $c->getData( new client ); TO SET DEFAULT VALUE LIKE class controller{ function getData(client $client = new client){ } } $c = new controller; $c->getData(); 
Source Link

PHP method class variable

is it possible set method variable default value if variable is expected to be "new class"

class controller{

function getData(client $client){ } 

}

$c = new controller; $c->getData( new client );

TO SET DEFAULT VALUE LIKE

class controller{

function getData(client $client = new client){ } 

}

$c = new controller; $c->getData();