It’s easy to create a file having php extension in php .Simply write a file with php extension as others mentioned.
But I would rather write an ini file for configuration data and load them later with parse_ini_file.
Update: Here is an example to do that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php $config = array( "database" => "test", "user" => "testUser" ); function writeConfig( $filename, $config ) { $fh = fopen($filename, "w"); if (!is_resource($fh)) { return false; } foreach ($config as $key => $value) { fwrite($fh, sprintf("%s = %s\n", $key, $value)); } fclose($fh); return true; } function readConfig( $filename ) { return parse_ini_file($filename, false, INI_SCANNER_NORMAL); } var_dump(writeConfig("test.ini", $config)); var_dump(readConfig("test.ini")); |