Welcome Guest, Not a member yet? Register   Sign In
<? and <?php
#1

[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 Smile 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 Wink

psConfusedorry for my bad english Big Grin
#2

[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.
#3

[eluser]Ngulo[/eluser]
thanks ,this is the answer i was looking for Wink

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?
#4

[eluser]JanDoToDo[/eluser]
Correct
#5

[eluser]Ngulo[/eluser]
perfect thank you Wink
#6

[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.
#7

[eluser]nelson.wells[/eluser]
Oops, I stand corrected. PHP 6 does deprecate them, though.
#8

[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 Wink
#9

[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.




Theme © iAndrew 2016 - Forum software by © MyBB