Jump to content

[SOLVED] PHP5 is <?php required or can <? be used


acctman

Recommended Posts

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);
                }

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.