• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

writing configuration files in php?

aximbigfan

New Member
Joined
Oct 15, 2006
Messages
847 (0.13/day)
Location
St. Louis, MO
System Name QUAD1
Processor Intel Core i7 920
Motherboard Asus P6T SE
Cooling XIGMATEK HDT-S963
Memory OCZ 3 X 1GB Triple Channel
Video Card(s) HIS Radeon HD4670 IceQ
Storage Seagate 250GB 7200RPM SATA
Display(s) Acer AL1916W 19" Widescreen LCD
Case CM Storm Scout
Audio Device(s) Onboard
Power Supply Corsair 520 Watt
Software Windows XP Pro
Anyone know how to write configuration files in PHP?

I have though of a few ways, but non work really well.

Basically, I just want to write variables and values, to be used by a PHP app for its configuration.

For example

have a webui where the user says that they want "white" to be a background color, and "blue" be the text color. So they click on submit, and the PHP script opens config.php, and writes the following to it...

$bgcolor = "white";
$textcolor = "blue";


Chris
 

y2kbugger

New Member
Joined
Dec 24, 2007
Messages
14 (0.00/day)
Location
austintown, oh
would this be per user, or like a site admin?
 
Joined
Aug 10, 2007
Messages
4,267 (0.70/day)
Location
Sanford, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
If you're on php5, file_put_contents() wraps up fopen(), fwrite() and fclose() into one nice little function.

PHP:
// Possibly done during account creation with default values
$userInfo = array('BgColor' => '#FFFFFF', 'TxtColor' => '#000000');
file_put_contents('user.info', serialize($userInfo));

// Pulling the values...
$userInfo = unserialize(file_get_contents('user.info'));

Depending on how you identify users, could save them as $username.'whatever'.
 

aximbigfan

New Member
Joined
Oct 15, 2006
Messages
847 (0.13/day)
Location
St. Louis, MO
System Name QUAD1
Processor Intel Core i7 920
Motherboard Asus P6T SE
Cooling XIGMATEK HDT-S963
Memory OCZ 3 X 1GB Triple Channel
Video Card(s) HIS Radeon HD4670 IceQ
Storage Seagate 250GB 7200RPM SATA
Display(s) Acer AL1916W 19" Widescreen LCD
Case CM Storm Scout
Audio Device(s) Onboard
Power Supply Corsair 520 Watt
Software Windows XP Pro
If you're on php5, file_put_contents() wraps up fopen(), fwrite() and fclose() into one nice little function.

PHP:
// Possibly done during account creation with default values
$userInfo = array('BgColor' => '#FFFFFF', 'TxtColor' => '#000000');
file_put_contents('user.info', serialize($userInfo));

// Pulling the values...
$userInfo = unserialize(file_get_contents('user.info'));

Depending on how you identify users, could save them as $username.'whatever'.

Thanks Jizzler!

Chris
 
Top