I’m working on a Content Management System, and so far so good.
I’m trying to get the system to work with a maintenance mode system.
This is the code in the script to display the maintenance stuff:
if ($maintenance['value'] == "1") {?>
<div id="content">
<div id="errmsg">
<?php echo $maintenance['notes']; ?>
</div>
</div>
<? } else {?>
<h1><?php echo $title; ?></h1>
<hr /><br />
<div id="content">
<?php echo $contents;
if (!$content) {
include ('includes/error/404.php');}?>
</div>
<? } ?>
I can verify that the $maintenance[‘value’] variable is working as it should, but this portion o the script isn’t working as it should. The value is currently set to 1, but it still displays the stuff in the else.
Any ideas?
I second Cassy’s proposed notation. My remarks:
I’m not really sure how PHP really handles datatypes but I just checked this site and according to this, your expression should evaluate to true, even if
$maintenance['value']holds the integer1(you are comparing it to the string"1").What is the other value,
$maintenance['value']can hold? “0”? If so, why not just assignTRUEandFALSEto the variable, to be on the save side? Anyway, maybe you can try just to write your expression like this:This evaluates to
TRUEif$maintenance['value']holds any of these values: