我的方法在类内,但我仍然收到
错误:语法错误,意外的“公共”(T_PUBLIC),期望在第1行的文件结束。
可能是因为我在用php写php文件
文件编写代码:
$file_data_write = "\n".'public function '.$table_name.'(){' . "\n" . '$this->load->view("'.$view_location.'");' . "\n" . '}'. "\n" . '}';
$file_location = APPPATH."controllers/". $view_and_controller_location;
$file_name = "/" . $view_and_controller_location . ".php";
$myfile = fopen($file_location . $file_name, "r+") or die("Unable to open file!");
fseek($myfile, -2, SEEK_END);
fwrite($myfile, $file_data_write);
fclose($myfile);
类我写信给
class Student extends CI_Controller {
public function six(){
$this->load->view("student/six");
}
}
发布于 2018-08-17 05:14:55
您可能要做的是在类结束}或php结束语法之后添加函数。
class Test
{
}
?>
public function ... {
}
类外不可能有“公共”函数,究竟是什么错误告诉了您
或者您正在重写文件,而不是在末尾添加,因此公共函数将在一行中。
https://stackoverflow.com/questions/51895796
复制