PHP mysqli: init() function
mysqli_init() function / mysqli::init
The mysqli_init() function / mysqli::init -- mysqli_init initializes MySQLi and returns an object to use with the mysqli_real_connect() function.
Syntax:
Object oriented style
mysqli mysqli::init ( void )
Procedural style
mysqli mysqli_init ( void )
Usage: Procedural style
mmysqli_init();
Return value:
Returns an object.
Version: PHP 5, PHP 7
Example:
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Perform queries
$sql1="CREATE TABLE orders LIKE employees";
mysqli_query($con,$sql1);
$sql2="INSERT INTO orders SELECT * FROM oldorders ORDER BY Last_Name LIMIT 10";
mysqli_query($con,$sql2);
// Print info about most recently executed query
echo mysqli_info($con);
mysqli_close($con);
?>
See also
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/php/function-reference/mysqli_init.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics