Programming MCQs Feed

📊 PHP
Q. Which PHP function checks if a path is a directory?
  • (A) is_dir()
  • (B) is_folder()
  • (C) dir_exists()
  • (D) folder_check()
💬 Discuss
✅ Correct Answer: (A) is_dir()

Explanation: is_dir() checks whether the path is a directory.

📊 PHP
Q. Which PHP function reads the entire file into a string?
  • (A) file()
  • (B) fread()
  • (C) readfile()
  • (D) file_get_contents()
💬 Discuss
✅ Correct Answer: (D) file_get_contents()

Explanation: file_get_contents() reads file content into a string.

📊 PHP
Q. Which PHP function writes data to a file?
  • (A) write_file()
  • (B) file_write()
  • (C) file_put_contents()
  • (D) fwrite_all()
💬 Discuss
✅ Correct Answer: (C) file_put_contents()

Explanation: file_put_contents() writes data to a file.

📊 PHP
Q. Which PHP function deletes a file?
  • (A) delete()
  • (B) remove()
  • (C) unlink()
  • (D) erase()
💬 Discuss
✅ Correct Answer: (C) unlink()

Explanation: unlink() deletes a file.

📊 PHP
Q. Which PHP function creates a directory?
  • (A) dir_create()
  • (B) make_dir()
  • (C) mkdir()
  • (D) create_folder()
💬 Discuss
✅ Correct Answer: (C) mkdir()

Explanation: mkdir() creates a directory.

📊 PHP
Q. Which PHP function removes a directory?
  • (A) remove_dir()
  • (B) delete_dir()
  • (C) rmdir()
  • (D) unlink_dir()
💬 Discuss
✅ Correct Answer: (C) rmdir()

Explanation: rmdir() deletes an empty directory.

📊 PHP
Q. Which PHP function retrieves environment variables?
  • (A) env()
  • (B) getenv()
  • (C) $_ENV
  • (D) Both getenv() and $_ENV
💬 Discuss
✅ Correct Answer: (D) Both getenv() and $_ENV

Explanation: Environment variables can be accessed using getenv() or $_ENV.

📊 PHP
Q. Which PHP superglobal stores server and execution environment info?
  • (A) $_ENV
  • (B) $_SERVER
  • (C) $_SESSION
  • (D) $_REQUEST
💬 Discuss
✅ Correct Answer: (B) $_SERVER

Explanation: $_SERVER contains server and execution details.

📊 PHP
Q. Which PHP function gets the current working directory?
  • (A) pwd()
  • (B) getcwd()
  • (C) current_dir()
  • (D) cwd()
💬 Discuss
✅ Correct Answer: (B) getcwd()

Explanation: getcwd() returns the current working directory.

📊 PHP
Q. Which PHP function changes the current directory?
  • (A) setcwd()
  • (B) chdir()
  • (C) cd()
  • (D) change_dir()
💬 Discuss
✅ Correct Answer: (B) chdir()

Explanation: chdir() changes the current directory.