Post by fluxman » Fri Feb 29, 2008 5:49 pm

Firstly, congratulations on an awesome shopping cart system. It's the nicest I've seem!

I have a small improvement for your php templating system.
Instead of

Code: Select all

<?php if ($stock == 0) { ?>
    <p>Out of stock you idiot.</p>
    <p>more html</p>
<?php } else { ?>
    <p>Today is your lucky day, loser.</p>
    <p> We have <?php echo $STOCK; ?> of these in stock!</p>
<?php } ?>
I prefer to use:

Code: Select all

<?IF($STOCK==0:?>
    <p>Out of stock you idiot.</p>
    <p>more html</p>
<?ELSE:?>
    <p>Today is your lucky day, loser</p>
    <p> We have <?=$STOCK?> of these in stock!</p>
<?ENDIF?>
I think it looks a not nicer to use the relatively uknown if: elseif: endif syntax in templates, and it's more user friendly for understanding the general flow of the template for people who don't know php that well, and it means you don't have to use curly braces {}. I also use short tags (bad, I know..but if you're in control, it's not too bad), and the short-tags echo shortcut of '<?='  ... also you don't need semi-colons. Finally, I use uppercase for all template php and variables, to make the template code stand out even more

It's not necessarily an "improvement", but I think it makes templates easier to read.

I guess the only drawback is that the if: elseif: endif syntax isn't standard, and might become unsupported in future php....and of course you shouldn't really use shorttags...

Keep up the good work!
Last edited by fluxman on Fri Feb 29, 2008 5:54 pm, edited 1 time in total.

Newbie

Posts

Joined
Fri Feb 29, 2008 5:40 pm

Post by hm2k » Wed Mar 12, 2008 6:50 am

<? is depreciated in php5, due to confusion with XML, it should be <?php

UK Web Hosting


User avatar
Global Moderator

Posts

Joined
Tue Mar 11, 2008 9:06 am
Location - UK
Who is online

Users browsing this forum: No registered users and 2 guests