我正在写一个txt文件来备份某些帖子。这是我的简单代码
$this->path = APPPATH . "post_backups/"; $string = $this->input->post('post'); $post_title = $this->input->post('post_title'); $this->file = $this->path . $post_title."txt"; write_file($this->file, $string); $this->index();
除此之外,一切正常
$this->file = $this->path . $post_title."txt";
我试图用文章的标题命名我的文件,即:title.txt。
我得到的是这个“标题文本”。$post_标题应该如何。”TXT“是否编写为提供TXT作为扩展名?
谢谢
$this->file = $this->path . $post_title.".txt";
未引用, . 用于连接字符串,因此只需在字符串中添加一个句点。在引号中,它被视为字符文本。
.