DEV Community

Discussion on: How to read dot files with PHP?

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited

.htconfig.ini

[MySQL]
dsn = "mysql:host=localhost;dbname=myDatabase"
user = "username"
password = "Password"

index.php

<?php
$config = parse_ini_file('.htconfig.ini' , true);
$db = new MyPDO($config['MySQL']);
Collapse
 
ashokcodes profile image
Ashok Mohanakumar

Wow! thanks, I looked into this. It looks better than using normal dot files since there is a built in function to read ini files. Thanks a lot