Welcome Guest, Not a member yet? Register   Sign In
CI 1.7: Will automatic short tags be deprecated?
#1

[eluser]MMacdonald[/eluser]
1.7 is a fantastic release that has fixed my 2 biggest annoyances. But I noticed a new style guide, which appears to drop hints that in the future we may see more "approved" 3rd party libraries. On the subject of short tags the style guide says the following:

Quote:Short Open Tags

Always use full PHP opening tags, in case a server does not have short_open_tag enabled.

INCORRECT:
<? echo $foo; ?>

<?=$foo?>

CORRECT:
<?php echo $foo; ?>

However, the alternative PHP syntax page still suggests support for automatic short tags in those cases where the server does not have short_open_tag enabled. This seems an inconsistent message.

My question is: will short tag support be deprecated in future versions? I personally like them, because they keep the code looking cleaner, but if they're generally considered bad practice, I'll welcome guidance on this.
#2

[eluser]Yash[/eluser]
why bad practice?

I always like these short tags.
#3

[eluser]xwero[/eluser]
Short tags are a php.ini setting an this can be switched off. CI has a build-in parser for short tags but this slows down the page rendering.

I think the idea behind that rule is to write code that works on every server. So if you still want to use short tags make sure you switch them on, on your server.

You have to read the style guide as a guide and not as documentation. I think the use of incorrect and correct should be replaced by don't use and use. As you demonstrated the wording can confuse people.
#4

[eluser]Pascal Kriete[/eluser]
Quote:My question is: will short tag support be deprecated in future versions?
More the other way around, actually. The style guide is copied from EE's developer guidelines. EE doesn't have the option to rewrite short tags, but it will (theoretically) when EE 2 comes out.
I follow a pretty basic rule here. Long syntax for open source. Short tags if I can control the environment.
#5

[eluser]Derek Allard[/eluser]
I love reading threads when xwero and inparo have written. Always bang on... thanks guys.

To be explicit, the guide is a guide which we tried to use to make people's code similar, but short tags are certainly fine. Short tag rewriting won't be deprecated in the near future.
#6

[eluser]Yash[/eluser]
ok I got the point.. I'll keep this in my mind for future while writing open sources..
#7

[eluser]Sarre[/eluser]
[quote author="xwero" date="1224863241"]CI has a build-in parser for short tags but this slows down the page rendering.[/quote]
Does this mean that a site coded using short tags will run slower than one coded with the full "echo" statements?
And if so, is there a large difference in speed?
#8

[eluser]xwero[/eluser]
Sarre it depends on the rewrite_short_tags setting. If it's set to true all files will be checked for short tags. loader class snippet :
Code:
if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
        {
            echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
        }
I have no figures on the performance hit but if the setting is false the file just gets included.




Theme © iAndrew 2016 - Forum software by © MyBB