+ 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();

26th Feb 2018, 8:27 AM
Pravin Pandey
Pravin Pandey - avatar
11 odpowiedzi
+ 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(); ?>
26th Feb 2018, 9:35 AM
jay
jay - avatar
+ 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
26th Feb 2018, 9:59 AM
jay
jay - avatar
+ 7
That make it easier to understand, thanks!
26th Feb 2018, 9:57 AM
jay
jay - avatar
+ 7
that space though right :)
26th Feb 2018, 1:16 PM
jay
jay - avatar
+ 6
I already reported but the question still appears in every challenge.
26th Feb 2018, 8:31 AM
Pravin Pandey
Pravin Pandey - avatar
+ 6
@jay $name = 'Daniel'; __________getName() { global $name; _____$______; } getName();
26th Feb 2018, 9:53 AM
Pravin Pandey
Pravin Pandey - avatar
+ 5
Thanks @Jay
26th Feb 2018, 10:23 AM
Pravin Pandey
Pravin Pandey - avatar
+ 4
You can report this question after completing the challenge
26th Feb 2018, 8:29 AM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 4
@Jay what can we do about this?
26th Feb 2018, 10:08 AM
Pravin Pandey
Pravin Pandey - avatar
+ 4
Yes.
26th Feb 2018, 1:29 PM
Pravin Pandey
Pravin Pandey - avatar
+ 2
@Jay query have been solved and its showing right answer. Thanks!
26th Feb 2018, 1:01 PM
Pravin Pandey
Pravin Pandey - avatar