Example 1 — Ping a Fresh Connection
A newly opened connection normally answers the ping. Sample output is fixed.
<?php
$mysqli = mysqli_connect("localhost", "demo_user", "demo_pass", "app_db");
var_dump(mysqli_ping($mysqli));
mysqli_close($mysqli); How It Works
- Connect with placeholder credentials.
- mysqli_ping() asks the server if the link still works.
- true means the connection is alive in this sample.
- Close afterward.

