I am trying to understand the use of double apostrophe on PHP function arguments. The code looks like this:
public function get_list($men="",$women="",$other=""){
// TO-DO
}
What is the use of the double apostrophe in the arguments as in $men=""
and can you please recommend where I can read about it?
It means that if there's no value within these variables then it'll by default take empty values.
public function get_list($men="",$women="",$other=""){
echo "Hello $men or $women , $other";
}
Calling function without parameters
get_list();//Hello or ,
Calling function with first parameters value
get_list('Lenny Carmi');//Hello Lenny Carmi or ,
Calling function with second parameters value
get_list('','Lenny Carmi');//Hello or Lenny Carmi ,
Calling function with third parameters value
get_list('','','Lenny Carmi');//Hello or , Lenny Carmi
Calling function with all parameters value
get_list('men','women','other');//Hello men or women , other
They are default argument values containing an empty string.