1

I am writing to a txt file to back up certain posts. Here is my simple code

$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(); 

Every thing works fine except this

$this->file = $this->path . $post_title."txt"; 

I am trying to name my file with the title of the post IE: title.txt.

What I am getting it s this "titletxt". How should the $post_title . "txt" be written to provide txt as an extension?

Thanks

1 Answer 1

1
$this->file = $this->path . $post_title.".txt";

Not quoted, . is used to concatenate strings, so just add a period to your string. Inside the quotes it's treated as a character literal.

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! the simplest things are always the hardest to see. Thank you very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.