+ 7
[SOLVED] [WRONG QUESTION] Wrong PHP Question
Hello Dear Moderators, I would like to bring to your kind attention towards following PHP question which is actually wrong due to a white space after (function) in second line of code or may be something else, even when we enter write keywords the answers shows wrong and this particular question appears in almost every challenge. The Question Is... $name = 'Daniel'; __________getName() { global $name; _____$_____ Answer should be... $name = 'Daniel'; function getName() { echo $name; } getName();
11 Antworten
+ 8
.. what are the answer options? Is it multiple choice? or is a text field available.
What is the actual question. You have only provided the code for the question.
If there is space for a written answer, have you tried error?
The code sample you provided will produce an error because the variable $name is not defined inside the function getName()
Research variable scope.
The correct code to produce the answer Daniel would be:
<?php
$name = 'Daniel';
function getName() {
global $name;
echo $name;
}
getName();
?>
+ 8
I think there is something else wrong with the question, as the correct code 'should' be:
https://code.sololearn.com/wP6yQQBYG9tT/?ref=app
Thanks for your feedback
+ 7
That make it easier to understand, thanks!
+ 7
that space though right :)
+ 6
I already reported but the question still appears in every challenge.
+ 6
@jay
$name = 'Daniel';
__________getName() {
global $name;
_____$______;
}
getName();
+ 5
Thanks @Jay
+ 4
You can report this question after completing the challenge
+ 4
@Jay what can we do about this?
+ 4
Yes.
+ 2
@Jay query have been solved and its showing right answer. Thanks!