scrubbicus Posted December 16, 2009 Share Posted December 16, 2009 So I've seen some short hand PHP syntax before and I've tried using it on my scripts and it wouldn't work, syntax such as <?=$message?> I just started taking a look at Code igniter today and I realized you have to enabled it in this framework, does anyone have a tutorial on how to write a script, or if it's a system setting, do that so I can use this shorthand in my work outside of frameworks? Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/ Share on other sites More sharing options...
cags Posted December 16, 2009 Share Posted December 16, 2009 It requires short_open_tag to be set to On in your PHP.ini file. It's also generally frowned upon because your code is no longer as portable. Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/#findComment-978718 Share on other sites More sharing options...
scrubbicus Posted December 16, 2009 Author Share Posted December 16, 2009 Well when I try to write this shorthand on files outside the Code Igniter framework but still in my localhost I can't get it to work, so I'm presuming I don't have that enabled in the php.ini file but it's still working within that framework? Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/#findComment-978741 Share on other sites More sharing options...
mrMarcus Posted December 16, 2009 Share Posted December 16, 2009 <?= is only 2 characters shorter than a proper full tag <?php and how often are you really writing an open tag anyways that would make adding those 2 extra characters so consuming? stick with full tags as cags says, and stay portable. or we'll be seeing you soon enough asking why you're code no longer works since your host upgraded their servers. Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/#findComment-978742 Share on other sites More sharing options...
cags Posted December 16, 2009 Share Posted December 16, 2009 Perhaps the framework handles code differently, I don't know, I have never worked with Code Igniter. <?= is only 2 characters shorter than a proper full tag <?php and how often are you really writing an open tag anyways that would make adding those 2 extra characters so consuming? stick with full tags as cags says, and stay portable. or we'll be seeing you soon enough asking why you're code no longer works since your host upgraded their servers. Actually it's not only two characters shorter. <?= $var ?> is shorthand for <?php echo $var; ?> which is more like 8 characters shorter. But the point still stands. Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/#findComment-978743 Share on other sites More sharing options...
salathe Posted December 16, 2009 Share Posted December 16, 2009 CodeIgniter parses short tags in files and converts them to "normal" code at runtime. Helpful links: http://codeigniter.com/user_guide/general/alternative_php.html Line 673 of http://dev.ellislab.com/svn/CodeIgniter/trunk/system/libraries/Loader.php Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/#findComment-978755 Share on other sites More sharing options...
Daniel0 Posted December 16, 2009 Share Posted December 16, 2009 There is not anything inherently wrong with the short tags. If you can control the environment where they'll be used, I see no issue using it. For instance, on PHP Freaks I could turn short tags on and use them if I wanted to. That would be no problem whatsoever. Link to comment https://forums.phpfreaks.com/topic/185391-rewrite-short-tags/#findComment-978780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.