Multiple choice php

What is the correct way to connect to a MySQL database?

  1. mysql_open("localhost");

  2. connect_mysql("localhost");

  3. dbopen("localhost");

  4. mysql_connect("localhost");

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

mysql_connect() was the standard function to connect to MySQL databases in PHP 4 and early PHP 5 (before PDO or mysqli were introduced). Options A, B, and C use non-existent function names. Note that mysql_* functions are deprecated in PHP 5.5+ and removed in PHP 7.0.