这里需要一些PHP帮助,包含的内容显示为'1',这意味着它的真实但需要它的内容才能显示,我不确定它为什么不是.这是一个缩短版的函数:
public function content {
$website->content = 'Some content here. ';
ob_start();
include('myfile.php');
$file_content = ob_end_clean();
$website->content .= $file_content;
$website->content .= ' Some more content here.';
echo $website->content;
}
Run Code Online (Sandbox Code Playgroud)
这输出:
Some content here 1 Some more content here
当我需要输出时:
Some content here 'Included file content here' Some more content here
我有什么想法可以解决这个问题吗?
我在我的静态函数中尝试调用CodeIgniter方法时遇到了麻烦,只是使用$这不起作用,因为它不在对象上下文中,静态关键字也不起作用.这是我的核心模型中的代码示例,$ table变量是从另一个模型(如posts)成功定义的.
class MY_Model extends CI_Model {
protected static $table;
public function __construct() {
parent::__construct();
}
public static function find_all() {
$this->db->select('*');
$sql = $this->db->get(static::$table);
return $sql->result();
}
}
Run Code Online (Sandbox Code Playgroud)