About Designerfoo and Me!

I am Manoj Sachwani, a webmaster, wannabe illustrator, designer, developer, amongst other things. I have over 14 years of experience, developing, designing and deploying websites. I am geeky, hairy and and I love what I do.

I stumbled & bought this domain - - because I thought it would be a "cool" domain to have, as time went on, I realized that I want to become - "Designerfoo" - and grow my knowledge in design, illustration, web design and web development.

I am webmaster, I design and develop websites with an edge. How may I help you?
Contact   -   @designerfoo   -   Facebook
Who is

PHP Shorthand and Alternate Syntax: A quickie!

DesignerfooDevelopment + PHP + Tutorial • 10-01
Please wait while you are redirected...or Click Here if you do not want to wait.
Subscrive via feedburner rss

Subscrive via feedburner email
15 Responses to “PHP Shorthand and Alternate Syntax: A quickie!”
Comment History Slider
    January 29, 2012 at 2:02 am
    Author: Adam Fowler

    This is a terrible practice, and no one should be using this. The shorthand If/Else statement is just about the only thing that is OKAY on this page.

      April 10, 2012 at 1:29 pm
      Author: Designerfoo

      Potato / Pototo :) Why is it so terrible? Care to explain?

    October 15, 2011 at 2:07 pm
    Author: kevin

    only thing i’d change is the lack of curly brackets. lol. great article!

    March 2, 2011 at 1:29 am
    Author: medina

    I’ve heard this alternative syntax will be ended up in the new version of the PHP, the 6.0. Could someone confirm it or not in definitely, please? Cheers.

    January 21, 2011 at 11:37 pm
    Author: MetroFax

    Handy page, very clearly laid out, and I was only aware of the {} syntax myself till I read this.

    I’d have to agree that the : method seems harder to read but still very simple and straight forward.

    You might be testing readership with the “IF Statement in one line” section but there’s two typos you may want to fix for the OCD types:
    “3 print $eatit = ($applet !=”gree”) ? “Eat” : “Dont Eat”;”
    should be
    “3 print $eatit = ($apple !=”green”) ? “Eat” : “Dont Eat”;”


      January 22, 2011 at 6:37 am
      Author: Designerfoo

      Thanks Metrofax :) for pointing out the typos, glad you enjoyed the article!

    July 12, 2010 at 2:19 pm
    Author: Jason

    You shouldn’t be advising people to use it, it’s pretty much the opposite of all the things you said it is.

    It’s ugly.
    It’s hard to read.
    It’s hard to debug.

    The ternary operator is okay, but normally in if statement is better due to readability.

    That’s just my opinion, probably the same as many others I’d say.

      July 13, 2010 at 5:31 am
      Author: Designerfoo


      To each his own? :) I love the : syntax, It’s more clear to me than using { }, I love {} too. It might be hard to debug I will give you that, but how is it that its hard to read and ugly? Ternary operators would save you a lot bytes if you have a lot of “if”s in the code. :) JMPO.

      July 20, 2010 at 6:17 am
      Author: Aaron

      using the if (…) :

      syntax is great if you have blocks of html code in between your php. I find it’s easier to scan for endif; or endwhile; when there is mixed html and php rather than searching through code looking for that missing curly brace ;)

        July 20, 2010 at 7:28 am
        Author: Designerfoo

        Agreed! :)

    January 22, 2010 at 10:00 pm
    Author: SeanJA

    Unfortunately I think they are deprecating short tags, so that one is out.

    As for the alternative syntax, I personally don’t like it because it forces you to look for the end tag instead of having your editor find it and highlight it {} (most editors that I have tried anyway). The syntax also reminds me of smarty…. which I hate. To each his own I guess.

      January 23, 2010 at 9:41 am
      Author: Designerfoo

      Yeah, thanks for the heads up the short tags.. Here is more on the topic of deprecating shot tags and its really sad that I would have to sit and change all my code replacing short tags to get it up to speed with PHP 6. They could have done better and worse.

      And yea, I don’t hate {}, I guess its my eyes :D
      on a serious note when you are developing on PHP all day long counting braces even with editors highlighting it, it does take time. I find using alternative sytax much better, to each his own! :) thanks for your comment!

Leave a reply :)



Mail (will not be published):




Eventify – Simple Events

NextGEN Resize Wordpress Plugin

Thanks to Subscribers

Thank you for taking the time out.

  X Close Feedback.