Asked  7 Months ago    Answers:  5   Viewed   37 times

I want to create a config file for my PHP project, but I'm not sure what the best way to do this is.

I have 3 ideas so far.

1-Use Variable

$config['hostname'] = "localhost";
$config['dbuser'] = "dbuser";
$config['dbpassword'] = "dbpassword";
$config['dbname'] = "dbname";
$config['sitetitle'] = "sitetitle";

2-Use Const

define('DB_NAME', 'test');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
define('TITLE', 'sitetitle');

3-Use Database

I will be using the config in classes so I'm not sure which way would be the best or if there is a better way.



One simple but elegant way is to create a config.php file (or whatever you call it) that just returns an array:


return array(
    'host' => 'localhost',
    'username' => 'root',

And then:

$configs = include('config.php');
Wednesday, March 31, 2021
answered 7 Months ago

Same problem with 000webhost and bluehost and ProISP, any PHP process running for more than 120 seconds will be terminated, regardless of settings, to prevent the server from overloading, and you must ask a engineer (that actually know what the problem is) for your account/script to get an exemption from this security feature (good luck. Only ProISP actually gave me an exemption for this, for 1 specific php script..) - or you could buy a VPS (ex, ) , or use a webhost that doesn't have this limitation (like ) , or use a webhost that might be willing to give you an exemption (like )

GoDaddy support staff are retarded. why? header( "refresh:30; url=" ); this will make YOUR BROWSER redirect and has nothing to do with php execution time, and they were unable to find the real cause of the problem, and the real problem has nothing to do with your cpu usage.

Wednesday, March 31, 2021
answered 7 Months ago

It's just a warning to show that there is no password for the default user root. If you want to set password for root:

  1. Open phpmyadmin interface
  2. Click "Users" tab
  3. Select user "root"
  4. Edit Privileges
  5. Change password
Saturday, May 29, 2021
answered 5 Months ago

i have done it by making an array

    $config = array (
        "{b0ff543d-d294-42c8-83eb-d72161ec6771}"  => '/var/www/youngib/rahul/'



Saturday, May 29, 2021
answered 5 Months ago

There is also PCLZip, a pure PHP alternative to ZipArchive that can be found at

Saturday, May 29, 2021
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :