<? and <?php |
[eluser]Ngulo[/eluser]
hi everyone, i'm new on this forum and new with CI,but i really enjoying it for me it's amazing this framework i'm just trying to understand what's the meaning of short tags <? compared to the simple tag <?php for example i'm using this code in a view.php: [code][<?=form_open('Home','id="form"');?> <?= form_close();?> /code] and it's so funny but the question is,why if i use this other code it doesn't works? [code][<?php=form_open('Home','id="form"');?> <?php= form_close();?> /code] maybe i didn't understand the meaning of <? short tag, can i use normal tags <?php ? wich are the main differences between these two ? if my hoster does not support PHP short tags maybe it could be a problem? thanks a lot and i think i will become a really "hot" CI fan psorry for my bad english
[eluser]nelson.wells[/eluser]
When you do the short tags with the equals sign, it will echo what is following it. <?=$hello;?> is equivalent to <?php echo $hello; ?> You should prefer the second option. It's a little more typing, but php short tags are deprecated and less portable.
[eluser]Ngulo[/eluser]
thanks ,this is the answer i was looking for so my code as written: [<?=form_open(‘Home’,‘id=“form”’);?> <?= form_close();?> /code] will become: [<?php echo form_open(‘Home’,‘id=“form”’);?> <?php echo form_close();?> /code] or wrong?
[eluser]cahva[/eluser]
[quote author="nelson.wells" date="1269218171"]When you do the short tags with the equals sign, it will echo what is following it. <?=$hello;?> is equivalent to <?php echo $hello; ?> You should prefer the second option. It's a little more typing, but php short tags are deprecated and less portable.[/quote] Short tags are NOT deprecated(I dont know why so many people think so). They are just not recommended because of portability. Some servers have this short open tag setting set to off and it can conflict with XML documents. Theres no other reason not to use it.
[eluser]nelson.wells[/eluser]
Oops, I stand corrected. PHP 6 does deprecate them, though.
[eluser]cahva[/eluser]
Where did you read this? Last time I checked, short tags will not be deprecated. Only ASP style tags are removed in PHP 6. Anyway, its safe to use short tags(in views) even if they deprecate it in the future as you can enable short tags from app config. So it will work even if this setting is off(or removed) from the server. Im no pro-short tags and use the longer format myself, but just wanted to mention that you can use them and its no sin
[eluser]danmontgomery[/eluser]
There's been no indication from the PHP development team to suggest that short tags are deprecated in PHP 6 (http://php.net/manual/en/ini.core.php, http://www.mail-archive.com/[email protected], http://wiki.php.net/rfc/shortags). It's frowned upon by some because it's a php.ini setting which is disabled by default on some PHP installations, but if they suit you then you and the needs of your application, should use them. |
Welcome Guest, Not a member yet? Register Sign In |