Jump to content

PHP Setting Script


01hanstu

Recommended Posts

As far as I know, it is not impossible to create a file and then fill it with PHP code, so I think this may help

<?php
$fileHandle=fopen("config.php", "w");
$stringToWrite="<?php  \$param1=$value1;
\$param2=$value2;
\$param3=$value3;
?>";
fwrite($fileHandle, $stringToWrite);
fclose($fileHandle);            /*Assuming that your data is - $value1, $value2 and $value3
Of course you may have any variable you want. The slash ("\") states as escaping character
*/
?>

 

Then when you have to use this file just include it

<?php include "config.php";?>

and use the variables you have already set (but here you are using $param not $value)

 

Hope this helps

----------------

Now playing: Timbaland - Way I Are (Feat. Keri Hilson & D.O.E.)

via FoxyTunes

Link to comment
https://forums.phpfreaks.com/topic/138872-php-setting-script/#findComment-726437
Share on other sites

You could use JSON or XML or YAML for this.  That would probably be simpler than a PHP file.

 

<?php
// write
$config['hostname'] = 'pterodactyl.com';
$config['username'] = 'iheartdinosaurs';
$config['password'] = 'rawr';

$fp = fopen('config.json', 'w');
fwrite($fp, json_encode($config));
fclose($fp);

// read
$config = json_decode(file_get_contents('config.json'));
print_r($config);
?>

Link to comment
https://forums.phpfreaks.com/topic/138872-php-setting-script/#findComment-726453
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.