Jump to content

Updating constants in a file


allex01

Recommended Posts

I have a file that contains all types of constants that looks like this

 

$CFG['admin']['value']['article_value'] = '9';

$CFG['admin']['value']['article_upload_value'] = '10';

$CFG['admin']['value']['game_comment_value'] = '11';

 

I created a form with input fields where a user can input and change the values for article_value, article_upload_value, game_comment_value. My question is , how can i make those values replace the current values in the constant file when the submit button is hit. You don't have to work with my current scheme. A simple example on how to update constants in a file would be helpfull. 

Link to comment
https://forums.phpfreaks.com/topic/91613-updating-constants-in-a-file/
Share on other sites

Do i still need to use fwrite()

 

If you want to actually overwrite the values in the file.

 

If you just want them temporarley overiden you would use something like....

 

<?php

  if (isset($_POST['submit'])) {
    $CFG['admin']['value']['article_value'] = $_POST['admin_value_article_value'];
    $CFG['admin']['value']['article_upload_value'] = $_POST['admin_value_article_upload_value'];
    $CFG['admin']['value']['game_comment_value'] = $_POST['admin_value_game_comment_value'];
  }

?>

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.