How would you declare a function that receives one parameter name hello?

If hello is true, then the function must print hello, but if the function doesn’t receive hello or hello is false the function must print bye.


function showMessage($hello=false){
  echo ($hello)?'hello':'bye';

In this question, the interviewer can evaluate if the developer knows how to declare a function and how they would manage the fact of the parameter can or cannot be on the function call. The interviewer can also evaluate if the developer knows the if syntax and if they knows how to print text(echo function).


© 2017