0

For days, this codes worked fine in my server:

<?php

$myname="alisha";

if($myname==="alisha"){
?>

<br/><br/><br/><br/><br/><br/>
<p>I am really Alisha</p>

<?

}

?>

But since hours ago, it doesn't work. But if I change it as:

<?php

$myname="alisha";
if($myname==="alisha") echo '

<br/><br/><br/><br/><br/><br/>
<p>I am really Alisha</p>
';

?>

It works fine. But I can't change all my php files into the last form because it's a lot. Please give me idea why it happens. Thank you.

3
  • 1
    Have you disabled PHP short tags?
    – dikesh
    Apr 11, 2014 at 14:25
  • What error do you get with the original code?
    – j08691
    Apr 11, 2014 at 14:25
  • did you change the short tags value in your config?
    – cptnk
    Apr 11, 2014 at 14:25

5 Answers 5

0

In your code

<?php

$myname="alisha";

if($myname==="alisha"){
?>

<br/><br/><br/><br/><br/><br/>
<p>I am really Alisha</p>

<?

}

?>

Its using short tag

so if server is upgraded then probably u need to set the php.ini to enable short tags.

short_open_tag=On

That way you do not need to change all the files.

0

your second open tag is missing php

<?php

$myname="alisha";

if($myname==="alisha"){
?>

<br/><br/><br/><br/><br/><br/>
<p>I am really Alisha</p>

<?php

}

?>
0

I would say there was an update for PHP, the INI file does not accept short opening tags any more and your second php part is not interpreted as PHP. Just always use <?php instead of <?

0

You have to enable to Short Open tag as Dikesh commented.

clean way :

<?php if($myname==="alisha"): ?>
 <br/><br/><br/><br/><br/><br/>
 <p>I am really Alisha</p>
<?php endif; ?>
0

You need to add "php" to your second open tag, best practice is to always include the "php" it will eliminate this problem and any others that can be caused by this.

<?php

$myname="alisha";

if($myname==="alisha"){
?>

<br/><br/><br/><br/><br/><br/>
<p>I am really Alisha</p>

<?php

}

?>

Side Note - if you using this content/script on a lot of pages i recommend using a include statement, it will elimitante the need to change one thing on multiple pages. http://www.php.net/manual/en/function.include.php

Also a cleaner way of writing this would be:

<?php if($myname==="alisha"): ?>
<br/><br/><br/><br/><br/><br/><p>I am really Alisha</p>    
<?php endif; ?>

Keep things short and simple :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.