|
Posted by The Eclectic Electric on 11/11/06 08:54
"Andy Hassall" <andy@andyh.co.uk> wrote in message
news:fge9l2t71hefhku9gf3int497njcg2oj5j@4ax.com...
> On Fri, 10 Nov 2006 16:40:35 GMT, "The Eclectic Electric"
> <nospam@spamispoo.spam> wrote:
>
>>Is there anything that can be used just as a "do nothing" line of code? I
>>wrote code to check user input on a "register" screen and I then re-used
>>it
>>to make a "change preferences" option. On the register screen, each field
>>of the form must be set, whereas on the change preferences screen, it
>>doesn't matter since I already have the information in session variables.
>>Rather than remove the first condition and reverse each of the tests I've
>>basically changed it to a meaningless stub of code, but this is processing
>>I
>>don't need to do. Is there a simpler way?
>>
>>Register processing:
>>
>>IF ( ( !ISSET( $_POST['userid'] ) ) || ( $_POST['userid'] == "" ) )
>> $_SESSION['err_userid'] = "1";
>>ELSE
>> {
>> // test other error conditions
>> }
>>
>>Update processing:
>>
>>IF ( ( !ISSET( $_POST['userid'] ) ) || ( $_POST['userid'] == "" ) )
>> $a = 0;
>>ELSE
>> {
>> // test other error conditions
>> }
>
> An empty pair of braces is valid syntax, and IMHO you should always
> include
> the braces even where they're optional (this is also part of the PEAR
> coding
> standards, which are mostly quite sensible).
>
> e.g.
>
> if (condition)
> {
> }
> else
> {
> }
>
> ... is valid and does nothing.
>
I can't believe I didn't think of that!!!! Thanks.
+e
[Back to original message]
|