Computer Science, asked by Anonymous, 11 months ago

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

Answers

Answered by mohmmedsufiyanali19
1

hey mate your answer is here

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.

Answer:

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

ihope u like my answer

Answered by EHSASS
2

ıllıllı ʜᴇʀᴇ ɪs ʏᴏᴜʀ ᴀɴsᴡᴇʀ ıllıllı

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, you 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. You can also evaluate if the developer knows the if syntax and how to print text(echo function).

ᴇʜsᴀss   (^_^)

Similar questions