The main difference is only your preferred style.
In most cases (possibly all), the function is a shortcut to the oo path.
These two calls are equivalents:
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db'); $mysqli = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');
because - essentially - the definition of mysqli_connect is as follows:
function mysqli_connect( $host, $user, $pass, $db ) { $conn = new mysqli( $host, $user, $pass, $db ); return $conn; }
Edit: long
See as an example the class of the third part simple_html_dom . Object oriented file upload method:
$dom = new simple_html_dom(); $data = file_get_contents( $url ) or die( 'Error retrieving URL' ); $dom->load( $contents ) or die( 'Error loading HTML' );
The above three lines can be compressed with a procedural call:
$dom = file_get_html( $url ) or die( 'Error loading HTML' );
because the internal code of file_get_html is as follows (simplified by me):
function file_get_html( $url ) { $dom = new simple_html_dom(); $contents = file_get_contents( $url ); if( empty($contents) || strlen($contents) > MAX_FILE_SIZE ) { return false; } $dom->load( $contents ); return $dom; }