Reputation: 25239
i'm using a very simple code
<? if ($_GET["end"]=='1') { ?>
<div id="header-message">
this is the message
</div>
<? } ?>
in my company server the code is ignored and the browser displays the DIV
on my personal server the message is not displayed unless the variable $end is !=""
i'm having hard time what can cause this issue...is a difference in phph 5.3.3 vs 5.4?? or else? or may code is wrong??
Upvotes: 0
Views: 89
Reputation: 14847
Try this: if ($_GET["end"]==1) instead of '1'.. if your php.ini allows short tags his code should work with too.
Maybe is read as integer in a case and as string in another.
Upvotes: 0
Reputation: 3972
1
means true
but "1" is a string
or '1'
. So you use only 1
or true
for check is true.
And use full tag <?php ... ?>
instead short <? ... ?>
Upvotes: 0
Reputation: 4449
Most likely, it is because you are missing the php
portion of your php tag.
<? if ($_GET["end"]=='1') { ?>
<div id="header-message">
this is the message
</div>
<? } ?>
Becomes
<?php if ($_GET["end"]=='1') { ?>
<div id="header-message">
this is the message
</div>
<?php } ?>
UPDATE
As others have stated, the first option is valid if you have the short_open_tag directive on. Please also be aware that as of PHP 5.4.0, you do not need to specify the short_open_tag directive.
Upvotes: 2