acctman Posted August 22, 2008 Share Posted August 22, 2008 PHP5 is <?php required or can <? be used? I asked this because i'm trying to fix a parsing problem with a template. which was design to only look for <? when processing PHP coding around the html coding //eval elseif (substr($value,0,2) == '<?' || substr($s,0,5) == '<?php') { // I edit this to look for <?php $this->act[$key] = 'do_eval'; } ----- # Eval function do_eval() { global $names, $en; extract($names); $ev = substr($this->s,2,-2); //right here its looking for just <? so thats the problem i'm having eval($ev); } Link to comment https://forums.phpfreaks.com/topic/120800-solved-php5-is-ltphp-required-or-can-lt-be-used/ Share on other sites More sharing options...
Stephen Posted August 22, 2008 Share Posted August 22, 2008 It depends if shorttags is enabled/disabled in your php.ini file. I haven't messed with php.ini much so you may want to look it up too. Link to comment https://forums.phpfreaks.com/topic/120800-solved-php5-is-ltphp-required-or-can-lt-be-used/#findComment-622660 Share on other sites More sharing options...
JasonLewis Posted August 22, 2008 Share Posted August 22, 2008 I've never used short tags personally. I like to use <?php and then echo, not this <?=$variable;?> or however it's done. Link to comment https://forums.phpfreaks.com/topic/120800-solved-php5-is-ltphp-required-or-can-lt-be-used/#findComment-622662 Share on other sites More sharing options...
nrg_alpha Posted August 22, 2008 Share Posted August 22, 2008 It is regarded as bad coding practice to use <? instead of <?php The reason for this is servers can be configured to disable short open tags (<? format) so as to avoid confusion with short hand XML tags..so by using <?php, you avoid all possible conflicting issues that could arise otherwise. Cheers, NRG Link to comment https://forums.phpfreaks.com/topic/120800-solved-php5-is-ltphp-required-or-can-lt-be-used/#findComment-622663 Share on other sites More sharing options...
acctman Posted August 22, 2008 Author Share Posted August 22, 2008 what would be the best way to fix the function do_eval() section of the coding so that it'll detect <? or <?php . Link to comment https://forums.phpfreaks.com/topic/120800-solved-php5-is-ltphp-required-or-can-lt-be-used/#findComment-622714 Share on other sites More sharing options...
nrg_alpha Posted August 22, 2008 Share Posted August 22, 2008 I would consider using something like str_replace.. so you could have for example: // assign $str to block of code with <? ?> stuff in it.. $str = str_replace("<?", "<?php", $str); or you can simply manually go through and make the changes by hand. If you use an IDE (such as dreamwaver), you can use the find and replace functionality.. that would work just as effectively. Link to comment https://forums.phpfreaks.com/topic/120800-solved-php5-is-ltphp-required-or-can-lt-be-used/#findComment-622720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.