我有一个包含一些代码的.cfg文件。我想在php页面中显示整个.cfg。代码为my_config.cfg在这里:
# ATA/IDE/MFM/RLL support
#
account_name=changl
#
# IDE, ATA and ATAPI Block devices
#
CONFIG_BLK_DEV_IDE=y
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_BLK_DEV_IDECD=n现在我写了一个php代码,它检查条件并显示我用echo写的内容。但是,我想显示文件中的所有内容。这里是php代码:
$config_file = "my_config.cfg";
$comment = "#";
$fp = fopen($config_file, "r");
while (!feof($fp)) {
$line = trim(fgets($fp));
if ($line && !preg_match("/^$comment/", $line)) {
$pieces = explode("=", $line);
$option = trim($pieces[0]);
$value = trim($pieces[1]);
$config_values[$option] = $value;
}
}
fclose($fp);
if ($config_values['account_name'] == "changl")
echo "account_name is changl";
else
echo "account_name is not changl";
?>代码工作正常。但我想在文件中显示数据。请任何帮助表示赞赏。