Page 1 of 1

Why fopen 1st Parameter Does Not Work ?

Posted: Sun Jun 18, 2017 5:52 pm
by UniqueIdeaMan
Fellow Programmers,

The following codes are supposed to creates 4 different files:

1.

Code: Select all


<?php

$ourFileName = "testFile_1.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);

?>


2.

Code: Select all


<?php

$ourFileName = "testFile_2.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileName);

?>


3.

Code: Select all


<?php

$ourFileHandle = fopen(testFile_3.txt, 'w') or die("can't open file");
fclose($ourFileHandle);

?>


4.

Code: Select all


<?php

fopen(testFile_4.txt, 'w') or die("can't open file");
fclose(testFile_4.txt);

?>


But why does the last 2 create files without the "." (dot) extension ?

Also, I have numbered all my 4 codes 1, 2, 3 & 4 but the thread shows all 4 codes numbered the same. Chrome and Fire Fox shows this.
Made a clip to demonstrate the issue. How can I send it to mods since this attachment refuses to upload video clips ?

Re: Why fopen 1st Parameter Does Not Work ?

Posted: Sun Jun 18, 2017 6:54 pm
by Christopher
The file names change. Is it possible you can open an existing file for writing, but not create new files?

Re: Why fopen 1st Parameter Does Not Work ?

Posted: Sun Jun 18, 2017 7:45 pm
by Pazuzu156
Also, you're forgetting to use quotes around the filenames in 3 and 4