0 votes
in PHP by
Which of the following is the correct way to open the file "sample.txt" as readable?

a) fopen("sample.txt", "r");

b) fopen("sample.txt", "r+");

c) fopen("sample.txt", "read");

d) fopen("sample.txt");

1 Answer

0 votes
by

(a) fopen("sample.txt", "r");

Description: The fopen() function accepts two arguments: $filename and $mode. The $filename represents the file to be opended and $mode represents the file mode for example, read-only, read-write, write-only etc. The "r" mode opens the file in read-only mode. It places the file pointer at the beginning of the file.

Related questions

+1 vote
asked May 11, 2022 in PHP by sharadyadav1986
0 votes
asked Oct 9, 2022 in JavaScript by Robin
...