【发布时间】:2013-01-20 08:38:27
【问题描述】:
我正在尝试使用 include_once() php api 将文件 (myfile.php) 的内容加载到另一个 (index.php) 中。但它没有加载内容。
// contents inside index page
if(include_once('myfile.php')){
echo D; // this is working
echo $b; // this is not working
} else {
echo "unable to include the file";
}
// contents inside myfile.php
define('D', '123');
$b = "abcd";
【问题讨论】:
-
include_once-call 是否驻留在函数内部? -
粘贴 myFile.php 可能 $b 是本地变量
-
确保所有代码(在
index.php以及myfile.php中)都正确包装在<?php ?>-tags 中。
标签: php include require-once