0

I want to create a text file with the name abc.txt .So I try this

$word="abc";

$file='"'.$word.".txt".'"'    //for having "abc.txt"

file_put_contents($file,'content content...'); 

And I have this error: Warning: file_put_contents("abc.txt"): failed to open stream: Invalid argument in C:....

Why this is not working? I mustn't use file_put_contents(abc.txt,'content content...'); Thanks

Kicker
  • 37
  • 4

1 Answers1

-1
$word = "abc";

$file = $word . '.txt';    //for having "abc.txt"

file_put_contents($file,'content content...'); 

"abc" is already in the variable and then you add '.txt';

stephangroen
  • 1,017
  • 10
  • 19