Where is error? I want '6 Yes' as output. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
31st Oct 2017, 1:09 PM
Mr_Yaman
Mr_Yaman - avatar
4 Answers
+ 5
"Notice: Undefined variable: answer...." It looks like $answer is not a global variable. It's local to the function, created and destroyed there. Putting a line break at line 5 between } and the function call may assist as a visual separation of 'variable scope'.
31st Oct 2017, 1:24 PM
Kirk Schafer
Kirk Schafer - avatar
31st Oct 2017, 2:26 PM
vaibhav sethi
vaibhav sethi - avatar
+ 1
global $answer; <-- put this in your func
1st Nov 2017, 9:15 PM
iizegrim
iizegrim - avatar
+ 1
Try this Function with global variable in php https://code.sololearn.com/w3zoxw3Ll9Al/#php
2nd Nov 2017, 5:47 AM
vaibhav sethi
vaibhav sethi - avatar