get_cfg_var and friends...
| From: | Flavien LEBARBE | Date: | Wed, 23 Feb 2000 12:22:51 +0000 |
| Subject: | get_cfg_var and friends... | ||
| Groups: | php.dev php.version4 | ||
| Request: | Send a blank email to php-dev+get-15828@lists.php.net to get a copy of this message | ||
Hello,
I'm playing around with config variables at the
moment, and I've got an "interesting" example. :)
Here's the code :
---
<?php
function display() {
echo
"get_magic_quotes_runtime()=".get_magic_quotes_runtime()."<BR>\n";
echo
"get_cfg_var('magic_quotes_runtime')=".get_cfg_var('magic_quotes_runtime')."<BR>\n";
}
?>
Current status :<BR>
<?php
display();
?>
Turn it on: set_magic_quotes_runtime(1);<BR>
<?php
set_magic_quotes_runtime(1);
display();
?>
Turn it off : set_magic_quotes_runtime(0);<BR>
<?php
set_magic_quotes_runtime(0);
display();
?>
---
And the result [magic_quotes_runtime are turned ON in my php.ini] :
---
Current status :
get_magic_quotes_runtime()=1
get_cfg_var('magic_quotes_runtime')=1
Turn it on: set_magic_quotes_runtime(1);
get_magic_quotes_runtime()=1
get_cfg_var('magic_quotes_runtime')=1
Turn it off : set_magic_quotes_runtime(0);
get_magic_quotes_runtime()=0
get_cfg_var('magic_quotes_runtime')=1
---
I also checked phpinfo display at every step and I
always get "magic_quotes_runtime ON ON" on this
example.
"magic_quotes_runtime" is just an example, same behaviour
with others.
Anyway... As I've looked at the code, I understand why I
get those values, but without, it's somewhat obscure...
I could have some ideas about how to make it more simple,
but what I don't understand at the moment is why there
are so many places where config vars are stored. Let's
go for a list :
* php_core_globals (the ones used by the PG macro), initialized
by compiled-in values, runtime modified, not all config
var are present.
* configuration_hash (static in configuration-parser.y,
used by get_cfg_var, has got the php.ini variables)
* known_directives (static in php_ini.c), used by php_info(),
contains master (ie compiled-in values overridden by their
values if any in php.ini), as well as the modified values
(.htaccess).
So, depending of the variable, there are up to 3 places
where its value can be found ! 8-)
Do I misunderstand something or miss some clever trick
behind all this ?
I'll be happy to spend some time with you guys to help
clarifying all this and/or/xor to developp a common
interface to access config vars if ever possible/acceptable.
Any ideas on this subject ?
Flavien Lebarbé.
--
Open Care