Page 1 of 1

read/write constants

Posted: Sun Jun 12, 2005 1:11 am
by sanders
Hi

I want to read/write constants in a file. To change the config with a browser.

<input type="text" name="testconstant">

output/change in a file
define("TESTCONSTANT", "Hello world.");

Is there a class for that?

Posted: Sun Jun 12, 2005 2:08 am
by anjanesh
Doubt that.
You'll have to write code to open the file and change the contant values by examining the lines.
Regular Expressions can be used for this.

Posted: Sun Jun 12, 2005 2:57 am
by sanders
Hi
Regular Expressions can be used for this
OK, but I hope there is already a solution. Found this: http://pear.php.net/package/Config

Have someone experience with that?

Posted: Sun Jun 12, 2005 9:26 am
by sanders
Hi

Another one
http://www.zend.com/manual/function.bco ... nstant.php
But only in PHP5?

I tried it with Regular Expressions. Not my world.

Has anybody a easy solution to handle this?

Posted: Sun Jun 12, 2005 9:42 am
by Buddha443556
Filter for it in your config file?

Code: Select all

if(isset($_GET['testconstant'])) {
    define("TESTCONSTANT", $_GET['testconstant']);
} else {
    define("TESTCONSTANT", "Hello world.");
}
Could use a little data checking too.

Posted: Sun Jun 12, 2005 10:59 am
by sanders
OK, thanks, but it must written statically in the config-file, not temporary. And I don't know, the Constants-Name (e.G. TESTCONSTANT) and how much Constants are in the file. It must be dynamic.

I think there is no existent solution for that (after 5 hours Google-Search). Probably I have to learn Regular Expressions. Arrggh.