TOMSW_ORG

Programming Beyond the Mass (scroll down)

During my projects, I have gained a lot of experience in things like programming style. Now I like to show you some examples how you could improve your programming skills. I will help you by writing several issues. This is the first!


About this post

Posted on 29. Mar 07 at 09:57
under Programming
and written by Tom

Keep in touch with the talk (RSS)


Using if...else more effectively

I am quite sure that most of you are confident users of the programm flow structurer if...else. In this first issue, I am trying to explain you how can use if…else more effectively respective that you can minimize your code to its minimum. The best is if I show you a simple example to show you what I mean.

function isEmpty($string)
{
    if ($string == null || trim($string) == "")
    {
        return true;
    }

    return false;
}

I don’t know but maybe some of you already know how to write this code snipplet in a shorter way. If not just look how I do it.

function isEmpty($string)
{
    return $string == null || trim($string) == "";
}

« Make Google to Your own Napster! // 8-Core Mac Officially Announced! »