if (function_exists('mysqli_connect')) {
echo "mysqli is installed";
}else{
echo " Enable Mysqli support in your PHP installation ";
}
Download files to test your MySQLI support

You can verify MySQLi installation by running a simple PHP script. This script will confirm if the MySQLi extension is enabled:
<?php
if (function_exists('mysqli_connect')) {
echo "MySQLi is installed and working.";
} else {
echo "MySQLi is not installed.";
}
?>
Once installed, you can create a basic connection to the MySQL database using MySQLi:
<?php
$host = "localhost";
$user = "root";
$pass = "password";
$db = "test_db";
$connection = mysqli_connect($host, $user, $pass, $db);
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully!";
?>
Adjust PHP runtime settings to enable MySQLi dynamically using ini_set(), useful for environments where you cannot directly edit php.ini file.
<?php
ini_set("mysqli.allow_local_infile", "1");
ini_set("mysqli.allow_persistent", "1");
echo "MySQLi runtime configurations adjusted!";
?>
If you're on Linux or macOS, you can install the MySQLi extension using package managers:
// For Ubuntu/Debian
sudo apt-get install php-mysqli
// For macOS with Homebrew
brew install php
Ensure that the MySQLi extension is enabled in your *php.ini* configuration file:
extension=mysqli
These additions explain how to check the MySQLi installation, test the connection, and give further instructions for enabling the MySQLi extension, providing a more comprehensive understanding of the installation process.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.