PHP alternative, lazy syntax
Alternative, lazy what?
Consider the next example:
';
echo ''.$oItem->title.'';
echo '';
} ?>
We could write the above like this:
Personally I think the second example is much easier to understand and a lot clearer for someone who isn’t familiar with PHP then the second one. (unfortunately my code highlight plugin thinks different though 😉 ) No braces in the code will also prevent some people to get the idea it’s to difficult to use PHP inside HTML and that integrating PHP into HTML is a task for PHP developers only. Also notice the advantage when indenting the HTML code.
Futher it helps me to distinguish in my own projects template files and controllers, models,… because of the different syntax. So when I have a a file with mixed PHP and HTML this is the preferred way for me.
Great! Let’s start using it!
Good idea but bear in mind that their are a few drawbacks:
- Not all servers allow the shorttags (check the short_open_tag entry in your php.ini file)
- Not using ; in the above example is a bad practice and should be avoided
- The most important one, their are other template engines on the market like Smarty, Dwoo, Savant, Template Blocks and a lot more that do the same thing but then easier or better (although you have minimal overhead)
Futher I should note their are some heavy discussions (still?) going on in the PHP community whether the short tags are genius or just plain evil. One thing is pretty sure now the short tags will still be available in PHP version 6.
For the complete list of the alternative syntax visit php.net
Please fill in the poll and leave a comment.
https://t.me/official_1win_aviator/38
DealerShadow
2 Nov 25 at 12:44 am
https://t.me/s/ud_JoycaSino
MichaelPione
2 Nov 25 at 12:49 am
https://t.me/s/official_1win_aviator/38
ChipWhisperer
2 Nov 25 at 12:56 am
https://t.me/s/UD_LegzO
MichaelPione
2 Nov 25 at 12:58 am
https://t.me/s/uD_dRagonMOneY
MichaelPione
2 Nov 25 at 3:03 am
https://t.me/s/official_1win_aviator/79
RouletteRogue
2 Nov 25 at 3:08 am
https://t.me/official_1win_aviator/60
PokerPhantom
2 Nov 25 at 3:32 am
https://t.me/official_1win_aviator/53
BluffMaster
2 Nov 25 at 3:45 am
https://t.me/s/UD_pinCo
MichaelPione
2 Nov 25 at 3:59 am
https://t.me/s/uD_daddy
MichaelPione
2 Nov 25 at 5:06 am
https://t.me/s/Ud_rIoBet
MichaelPione
2 Nov 25 at 5:14 am
https://t.me/s/uD_fRESH
MichaelPione
2 Nov 25 at 7:19 am
https://t.me/s/Ud_catcasINo
MichaelPione
2 Nov 25 at 8:39 am
https://t.me/s/UD_ROX
MichaelPione
2 Nov 25 at 9:30 am
https://t.me/s/UD_VULKAN
MichaelPione
2 Nov 25 at 9:39 am
https://t.me/s/tf_1win
CaseyAccuh
2 Nov 25 at 11:05 am
https://t.me/s/Top_bk_ru
TracyFat
2 Nov 25 at 1:03 pm
https://t.me/s/kfo_1win
TracyFat
2 Nov 25 at 1:11 pm
https://t.me/official_1win_aviator/48
HighRollerMage
2 Nov 25 at 1:13 pm
https://t.me/s/tf_1win
StevenHig
2 Nov 25 at 1:26 pm
https://t.me/s/Top_bk_ru
StevenHig
2 Nov 25 at 1:34 pm
https://t.me/s/kfo_1win
StevenHig
2 Nov 25 at 2:40 pm
https://t.me/s/official_1win_aviator/53
DealerShadow
2 Nov 25 at 4:09 pm