Home  • Programming • PHP

Which is the better way to connect with mysql database using mysqli

Which is the better way?

<?php
	$db = new MYSQLi("localhost","root","","001");
?>
or //---db_config.php
<?php 
 define('SERVER','localhost'); 
define('USER','root'); 
define('PWD',''); 
define('DB','supershop');
 ?>
//---demo.php
<?php
include_once("config.php");
$db = new MYSQLi(SERVER,USER,PWD,BD);

?>

Comments 8


About Author
Abdullah Al Mamun
Copyright © 2026. Powered by Intellect Software Ltd