Creating a config file in PHP

Subscribers:
10,300
Published on ● Video Link: https://www.youtube.com/watch?v=8lNkzMucwbU



Category:
Tutorial
Duration: 4:42
24 views
0


Best Way to create configuration file(config.php) php
my_config.ini vs my_config.php
Writing a configuration file in PHP
read, edit & save config files (php)
how to create configuration file in php

config.php

// Database Configuration
define('DB_HOST', 'localhost');
define('DB_USERNAME', 'your_username');
define('DB_PASSWORD', 'your_password');
define('DB_NAME', 'your_database_name');


require('config.php');

// Access the configuration settings
echo DB_HOST;


Method 2: Using JSON or INI Configuration File
config.json
{
"db_host": "localhost",
"db_username": "your_username",
"db_password": "your_password",
"db_name": "your_database_name",
"google_api_key": "your_google_api_key",
"debug_mode": true
}



// Read JSON configuration file
$configFile = 'config.json';
$configData = file_get_contents($configFile);
$config = json_decode($configData, true);

// Access the configuration settings
echo $config['db_host'];
echo $config['google_api_key'];



config.ini

db_host = "localhost"
db_username = "your_username"
db_password = "your_password"
db_name = "your_database_name"
google_api_key = "your_google_api_key"
debug_mode = "true"
// Read INI configuration file
$configFile = 'config.ini';
$config = parse_ini_file($configFile);

// Access the configuration settings
echo $config['db_host'];
echo $config['google_api_key'];
Method 1: Using a Plain PHP File
Please do like share and comment if you like the video please do hit like and if you have any query please write it comment box
NestJs Tutorial https://www.youtube.com/watch?v=9F6Cv_JHmrE&list=PLsvvBhdpMqBxYq1kxZoGhIEISCmXN0Pe2

You can support me by buying a coffee for me

https://ko-fi.com/N4N0JZBBN


Please do subcribe my other video tutorials
React Native Tutorial : https://www.youtube.com/watch?v=9aN93sM6OJQ&list=PLsvvBhdpMqBx0f2T7The14FV2sthRo_L5
ReactJS Tutorial : https://www.youtube.com/watch?v=5kBISm01zHg&list=PLsvvBhdpMqBzPZ75UzwbIQrPYk6NmFWiW
Linux Tutorials : https://www.youtube.com/watch?v=cJ4RmxbS1VM&list=PLsvvBhdpMqBz3yff6mYLc9BlhI0YVP7ZS
Jquery Tutorial : https://www.youtube.com/watch?v=wvPzvVn13xU&list=PLsvvBhdpMqBz3lROu38xphPSGXEl27U1d
Html & Css Tutorial : https://www.youtube.com/watch?v=yHV-I96ESBE&list=PLsvvBhdpMqBw5pNIDYgsIyr9giWVWwA2M
Wordpress Tutorial : https://www.youtube.com/watch?v=oBsaz2cYx6c&list=PLsvvBhdpMqByMSHXyehbldHx0o3EtvGuh
Javascript Tutorial : https://www.youtube.com/watch?v=Zbyd31hq3g8&list=PLsvvBhdpMqBySsqQsvMkOd9SpKQ_R2HDo
Magento 2 Tutorials : https://www.youtube.com/watch?v=84dNyRoQthQ&list=PLsvvBhdpMqBz_3k14bYpYEIPFI4MQporp
Github Tutorials : https://www.youtube.com/watch?v=N9Dfs4gUMjc&list=PLsvvBhdpMqByiaj7F289-nO26iBYc9ot9
October CMS Tutorial : https://www.youtube.com/watch?v=jFD2VUAxu2o&list=PLsvvBhdpMqBz027a08LovCuCAnU6T7VZx
Bash Scripting Tutorial : https://www.youtube.com/watch?v=yFV2QK-x6vY&list=PLsvvBhdpMqBx_jsVKKzZ9-ZZUwae9t4x9
Jenkins Beginner Tutorial : https://www.youtube.com/watch?v=GHQ8C_2OZps&list=PLsvvBhdpMqBzdLDMiMkFP5BaPqlXVuk45
Apollo Client React Js : https://www.youtube.com/watch?v=vGZGIfDlcvE&list=PLsvvBhdpMqBwJ5OjdxNCY_sw3PcHAXQlm
Wordpress Tutorial In Hindi : https://www.youtube.com/watch?v=Wt5vePyARA0&list=PLsvvBhdpMqBxmFcIrpJo0pZNJ7mmpKYZt
MongoDb Tutorial : https://www.youtube.com/watch?v=Mab0Hrx-mVA&list=PLsvvBhdpMqBxTopKc6hsh7BvPDLu_Emlr
Bootstrap 5 Tutorial in Hindi : https://www.youtube.com/watch?v=k7xGbXkVHy4&list=PLsvvBhdpMqBy_aSBZdtSJVcqSMsUAR4H1
Xero Tutorial For Beginners : https://www.youtube.com/watch?v=MOQ1hpd8CtI&list=PLsvvBhdpMqBxr3PDAnUzHJLlHvjtLWaQt
React Material UI = https://www.youtube.com/watch?v=CWtjF2Rx8I8&list=PLsvvBhdpMqBydNg7wU4A__7Qp65TyyhjA
Thanks for watching
Vue Js Tutorial : https://www.youtube.com/watch?v=k4O9TaUi4-U&list=PLsvvBhdpMqBy5pnwspDeDJo9JEzF3PKTh
Angular 14 Tutorial : https://www.youtube.com/watch?v=P3llhzCYgHE&list=PLsvvBhdpMqBwCbR5M-r6uNcgQu2BxuuQ8
MongoDb Tutorial : https://www.youtube.com/watch?v=Mab0Hrx-mVA&list=PLsvvBhdpMqBxTopKc6hsh7BvPDLu_Emlr
Mysql Tutorial For Beginners : https://www.youtube.com/watch?v=8IUu3iv3EEA&list=PLsvvBhdpMqBwleiAGlJIoMDEpJsZJjJSI
AWS Tutorials: https://www.youtube.com/watch?v=1a8WBUiz5gk&list=PLsvvBhdpMqBwGEnT2km4xNIL6wXJoVrLK
Php Tutorial for Beginners : https://www.youtube.com/watch?v=fCCtMVrHH_c&list=PLsvvBhdpMqBx0CHzCANLull6KkTlLh3Ac
Nest

Have a Great Day !!!




Other Videos By Technical Rajni


2023-09-22JSON Server Tutorial Fake REST API #8 Pagination
2023-09-22JSON Server Tutorial Fake REST API #7 Basic CRUD Operations DELETE requests
2023-09-22JSON Server Tutorial Fake REST API #6 Basic CRUD Operations PUT requests
2023-09-22JSON Server Tutorial Fake REST API #5 Basic CRUD Operations Sorting Data
2023-09-22JSON Server Tutorial Fake REST API #4 Basic CRUD Operations Filtering Data
2023-09-22JSON Server Tutorial Fake REST API #3 Basic CRUD Operations GET Request
2023-09-22JSON Server Tutorial Fake REST API #2 Getting Started with JSON Server
2023-09-22JSON Server Tutorial Fake REST API #1 Introduction
2023-09-22How do I change the default port in React Native
2023-09-21How to Calculate Distance, Travel Duration, Plot Routes, and Display Directions with Google Maps API
2023-09-21Creating a config file in PHP
2023-09-21Calculate Distance Between Two Addresses using Google Maps API PHP
2023-09-21Calculate Distance Between Two Addresses using Google Maps API Nodejs
2023-09-20How to send SMS using NodeJS for Free using Fast2sms India
2023-09-20Connect to MongoDB Atlas using NodeJS
2023-09-19Typescript Tutorial #73 When Do Decorators Execute
2023-09-19Typescript Tutorial #72 Creating parameter decorators Typescript
2023-09-18Typescript Tutorial #71 Creating Method Decorators typescript
2023-09-18Typescript Tutorial #70 Creating Accessor Decorators typescript
2023-09-18Typescript Tutorial #69 Creating Property Decorators Typescript
2023-09-18Typescript Tutorial #68 Creating Decorator Factories Typescript



Tags:
how to make a config file in php
how to create custom config file in laravel
create a text file in php
config file
create custom config file
how to create a text file in php
wp config file
php config file
how to create my own config file
edit config file
how to secure wp-config.php file in your wordpress website
file creation in php
edit wp-config.php in wordpress
wordpress site hacking by config php file
how to get data from config file