How to create a config file in php

Опубликовано: 07 Август 2026
на канале: eVidhya
8,440
38

How to create a config file in php
We create a file named config.php, to connect to the database. In this file, we firstly define the name of the server to connect,
then we define the username of the database server which by default is "root", then we define the password of the database server which by default is null, then we define the name of the database which we create, ex: login, in this case. After defining, we store the defined items in the MySQL function "mysqli_connect", which connects to the respective defined items of the database, and then store the mysqli_connect function into any user-defined variable, ex:$link in this case.

Finally, check for connection with the if condition, such as if $link is false prints ann error that it couldn't establish a connection to the database,
else print success.

In association with https://www.evidhya.com

Intro/ Outro Background song;
http://www.bensound.com/royalty-free-...


"Everyone must have access to knowledge, from anywhere, at any time, to everything They want to learn. Online courses are not harder or easier than the alternatives. They're just delivered differently. Online courses are designed for students at all learning levels. With eVidhya, you can learn from our tutorials and participate in accredited tests."

“There is no wealth like knowledge, and no poverty like ignorance”, Buddha.

Social;
  / evidhya.x  
  / evdhya  
Whatsapp; 00919535554254

Contribute;   / evidhya