PHP mysqli_init() Function

Definition

The mysqli_init() function initializes MySQLi and returns an object to use with the mysqli_real_connect() function.

Syntax

PHP mysqli_init() Function has the following syntax.

Object oriented style

mysqli mysqli::init ( void )

Procedural style

mysqli mysqli_init ( void )

Example

The following code uses of the mysqli_init() function to create an object for mysqli_real_connect() function.


<?php/*from   ww  w. jav  a 2  s  .  c o m*/
$con=mysqli_init();
if (!$con){
  die("mysqli_init failed");
}

if (!mysqli_real_connect($con,"localhost","my_user","my_password","my_db")){
  die("Connect Error: " . mysqli_connect_error());
}

mysqli_close($con);
?> 




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions