Sample code 3 lines of Text Flashcards

1
Q

Define the Filename: The variable _holds the name of the file where the text will be written.

A

$filename
<?php
**$filename **= “example.txt”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Open the File: The _ function is used to open the file in write mode (“w”). If the file does not exist, it will be created.

A

fopen()
$file = fopen($filename, “w”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write to the File: The ____ function is used to write each line of text to the file. The \n character is used to create a new line after each line of text.

A

fwrite()
if ($file) {
fwrite($file, “This is the first line of text.\n”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Close the File: After writing, the _ function is called to close the file, ensuring that all data is saved properly.

A

fclose()
fclose($file);
echo “Text written to $filename successfully.”; ?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly