Reply to Re: Code stubs

Your name:

Reply:


Posted by Andy Hassall on 11/10/06 17:44

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.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация