如果来自外部配置文件的语句不起作用 [英] If statement from external config file not working
问题描述
我有一个脚本,其中包含一个配置文件(名为accountsconfig.php),其中包含一个简单的布尔值:
I have a script that includes a config file (called accountsconfig.php) that contains a simple boolean:
<?php
$account = 'on';
?>
在我的主脚本上,我有一系列if else(如果$ account == true,do do这个,否则这个),但无论$ account的价值是什么,它总是会去其他地方(好像它甚至没有获得$ account的价值)。下面是我的一个ifelse示例:
On my main script, I have a series of if else (if $account == true, do this, else this), but its always going to the else no matter what the value of $account is (As if it doesnt even get the value of $account). Heres an example of one of my ifelse:
<?php
include('accountsconfig.php');
if ($account == 'on') { ?>
<select name="account_number" >
<option value="one">Account One</option>
</select>
<?php } else { ?>
<h1> HIII</h1>
<?php } ?>
此文件和accountsconfig.php位于同一目录中。
This file and the accountsconfig.php are located in the same directory.
* 更新: *
*UPDATE:*
如果我添加 <?php echo$ account?>
在else中,它显示off
If i add <?php echo "$account" ?>
between the in the else, it displays "off"
有什么建议吗?
推荐答案
如果使用===代替==作为其布尔值,请不要使用单词true
don't use the word true if you do the use === in stead of == as its boolean
使用另一个单词或数字来表示你在做什么1 /是2 /否
use another word or number to represent what you are doing 1/yes 2/no
这篇关于如果来自外部配置文件的语句不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!