这个问题是我在 vBulletin 系统中遇到的。我想在侧边栏区域构建一个 block 来帮助我自动化一些日常工作..我编写了这样的 php 代码:
<?php
$myDay = date('D');
$myHour = date('G');
// Saturday
if ($myDay == "Sat") {
if ($myHour >= 7) {
$output = include('textFilePath/saturday.txt');
} else {
$output = include('textFilePath/friday.txt');
}
}
// Sunday
if ($myDay == "Sun") {
if ($myHour >= 7) {
$output = include('textFilePath/sunday.txt');
} else {
$output = include('textFilePath/saturday.txt');
}
}
// and it goes on to friday...
// and in the end :
return $output;
?>
我的问题是 include() 函数。当我返回 $output 值时,它返回一个 bool 值(0 或 1),并且 include 函数在文档开头而不是“侧边栏 block ”中写出 txt 文件内容 我知道我可以回显实际内容,而不是使用 include 和 txt 文件。但正如我所说,我希望自动化日常任务并授予用户编辑 txt 文件的权限。
是否有其他技术或函数可以将本地文件的内容分配给变量?
最佳答案
您可能想检查
$output = file_get_contents('textFilePath/saturday.txt');
关于php - 分配一个等于 Include 函数内容的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10573018/