Answers

Question and Answer:

  Home  PHP Community Marketing Expert

⟩ Tell me 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.

<?php

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).

 149 views

More Questions for you: