函数名必须是第18行/var/www/html/fazrin/application/controllers/file.php中的字符串
此代码显示CodeIgniter中的以下错误消息: 遇到一个PHP错误 严重性:通知 消息:未定义变量:写入文件 文件名:controllers/file.php 电话号码:18 致命错误:函数名必须是中的字符串 /var/www/html/fazrin/application/controllers/file.php,第18行 这是第18行:函数名必须是第18行/var/www/html/fazrin/application/controllers/file.php中的字符串,php,codeigniter,web,writetofile,Php,Codeigniter,Web,Writetofile,此代码显示CodeIgniter中的以下错误消息: 遇到一个PHP错误 严重性:通知 消息:未定义变量:写入文件 文件名:controllers/file.php 电话号码:18 致命错误:函数名必须是中的字符串 /var/www/html/fazrin/application/controllers/file.php,第18行 这是第18行: class File extends CI_Controller { function __construct() {
class File extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('file');
}
function writetest()
{
$data = "Hello World!";
$file= "application.DIRECTORY_SEPERATOR.test_data.DIRECTORY_SEPERATOR.helloworld.txt";
$write_file($file,$data);
echo "finished writing";
}
无法在写入文件($file,$data)前面使用$
$write\u文件
不是变量,它是Codeigniter的函数。您将写入文件()
视为变量。因此,您必须删除'$write\u file($file,$data)
中的$
,如下所示:
$write_file($file,$data);
function __construct()
{
parent::__construct();
$this->load->helper('file');
}
function writetest()
{
$data = "Hello World!";
$file= "application.DIRECTORY_SEPERATOR.test_data.DIRECTORY_SEPERATOR.helloworld.txt";
write_file($file,$data);
echo "finished writing";
}