Jump to content

how to word a question


The Little Guy

Recommended Posts

Whether there is an error or not depends on what the expected behavior is seeing as there is nothing syntactically wrong with the snippet. Sometimes infinite loops are what you want, so they are not per definition errors. However, in this case it would be questionable whether an infinite amount of "Hello"s should be outputted. Furthermore, the usage of the HTML line break tag indicates it's to be on a web server and be served to a web browser. Seeing as the response would never be able to be sent to the client if the code never stops executing one can conclude that, yes, there is an error in the script.

Link to comment
Share on other sites

sorry, I meant to write yes, don't know why I wrote no.

 

So, what would be a better way to write the question, or would you leave the question as is?

No, "Is there an error in this code?" is a poor question - I wouldn't waste my time with the thread.

 

A help question should include:

  • What you are trying to make happen
  • What is actually happening
  • The environment it is running on, if appropriate
  • Effort made in expressing the problem

 

A better question would be:

I am trying to display 'Hello' ten times on my page, each on a new line but all I am getting is an error message telling me that my script has reached its maximum execution time after about 30 seconds. Could someone point me in the right direction please?

Link to comment
Share on other sites

A better question would be:

I am trying to display 'Hello' ten times on my page, each on a new line but all I am getting is an error message telling me that my script has reached its maximum execution time after about 30 seconds. Could someone point me in the right direction please?

 

As far as I understand, this question is a part of a quiz / test, and not a question asked in some board or for help.

 

 

So a good question for this piece of code would be:

What would the following code produce?

 

And if it's a multi choice question some possible options could be:

[*] 10 Times "Hello" each, in a new line

[*] An error, because echo has to come with parentheses around it's parameters.

[*] Nothing.

[*] An internal sever error.

etc'

 

 

Orio.

Link to comment
Share on other sites

As far as I understand, this question is a part of a quiz / test, and not a question asked in some board or for help..

 

After re-reading the original post - I think you may be right. My bad.

Link to comment
Share on other sites

As far as I understand, this question is a part of a quiz / test, and not a question asked in some board or for help..

 

After re-reading the original post - I think you may be right. My bad.

 

He is right.

 

I like how you worded it, I didn't run the code, but I would guess yours would be one of two things, either an "Internal server error", or "Nothing"

 

Reasoning:

Internal server error - the code would run endlessly, and make the script time out.

Nothing - the code would keep running till the time out, and no buffer will be able to push the code to the screen, since the buffer runs when the code has completly finished.

Link to comment
Share on other sites

Yeah, but I guess at some point you'll either get an internal 500 error or as SemiApocalyptic said, you'll get a "maximum execution time" error.

You can test it, but either way you have choose the answers wisely so you'll have no doubts about the correct answer.

 

Orio.

Link to comment
Share on other sites

Is there an error in the code?  That depends on how you want to interpret 'error'.  The 'correct' answer is "no, there is no error".  If there is an error, then point out which statement is wrong.

 

The fact (or presumption) that the code will produce no result, an unexpected result, or just crap out is not the outcome of an error.  Thinking there is an error derives from our tendency to think that anything that doesn't work 'right' must be wrong.

Link to comment
Share on other sites

I would say yes there is an error, but it isn't a syntax error, it is a logical error.

 

If this were to run from command line, then there would be no logical error (if you wanted an infinite loop), or any error at all. So I probably should say in the question something about it being run from the browser.

 

If you would like to take the test (AJAX test JavaScript required): http://phpsnips.com/tests/test.php?level=0

It is only 16 questions, where my current question is last.

If you take it, could you let me know about any other misleading questions, or wrong answers.

 

any ways how about this:

"What is the problem with this browser outputted code?"
A. Nothing
B. There is a syntax error
C. It is an endless loop
D. "hello<br>" must be in parenthesis

Link to comment
Share on other sites

Question 10 is misleading - is_int() checks a variable's type.

 

Question 11 is misleading, you could leave a loop with exit, you just wouldn't return to the rest of the script.

 

Question 21 is wrong. The answer is true. Firstly you can leave the semi-colon off the last line of your php code. It would also be debatable about what you mean by statement -- you do not need a semi-colon after an if statement.

Link to comment
Share on other sites

Question 10:

That is what the question asks, how to check for an integer type, at least that is what it is supposed to say.

 

Question 11:

As in C or Perl' date=' PHP requires instructions to be terminated with a semicolon at the end of each statement.[/quote']

http://us2.php.net/manual/en/language.basic-syntax.instruction-separation.php

 

Question 21:

an if is not statement, it is a construct, but it holds statements and it also contains expressions.

http://us2.php.net/manual/en/control-structures.if.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.