menu

PHP File Handling

PHP File Handling - Important Points


16. Which of the following is the correct way to open a file in PHP in binary mode?

A. fopen("file.bin", "rb");

B. fopen("file.bin", "r");

C. fopen("file.bin", "w");

D. fopen("file.bin", "a");

Discuss Work Space

Answer: option a

Explanation:

To open a file in PHP in binary mode, we need to use the "b" flag along with the mode. So, the correct way to open a file in binary mode is fopen("file.bin", "rb");

17. What is the function used to read a single character from a file in PHP?

A. fgetc()

B. fgets()

C. fread()

D. fgetss()

Discuss Work Space

Answer: option a

Explanation:

fgetc() is the function used to read a single character from a file in PHP.

18. Which of the following is the correct way to check the end of a file in PHP?

A. feof($file)

B. eof($file)

C. end_of_file($file)

D. is_eof($file)

Discuss Work Space

Answer: option a

Explanation:

feof($file) is the function used to check the end of a file in PHP.

19. Which of the following is the correct way to rename a file in PHP?

A. rename("oldname.txt", "newname.txt");

B. move("oldname.txt", "newname.txt");

C. change("oldname.txt", "newname.txt");

D. switch("oldname.txt", "newname.txt");

Discuss Work Space

Answer: option a

Explanation:

The correct way to rename a file in PHP is rename("oldname.txt", "newname.txt");

20. What is the function used to read a specific number of bytes from a file in PHP?

A. fread()

B. fgetc()

C. fgets()

D. fgetss()

Discuss Work Space

Answer: option a

Explanation:

fread() is the function used to read a specific number of bytes from a file in PHP.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now