Difference between get_cfg_var() and ini_get()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • flconseil@yahoo.fr

    Difference between get_cfg_var() and ini_get()

    Hi,

    I am writing a PHP library which uses some new configuration options in
    php.ini. To read the values in my code, I have the choice between
    get_cfg_var() and ini_get(). From the doc, I thought that they were
    working almost the same way, except that get_cfg_var() gets its value
    from the ini file, and ini_get() gives the current value, different if
    ini_set was called.

    Actually, when I have this line in php.ini :

    Autoload.preloa d_include_path = On

    I get this :

    get_cfg_var('Au toload.preload_ include_path') = string(1) "1" => OK

    ini_get('Autolo ad.preload_incl ude_path') = string(0) "" => Strange
    [color=blue]
    >From the doc again, it means that ini_get() fails.[/color]

    So, my questions are :

    - does ini_get() support only PHP predefined configuration options (or
    configuration options defined by an extension) ?
    - If it is not the case, why doesn't it read my option ?

    Thanks in advance

    François

  • Chung Leong

    #2
    Re: Difference between get_cfg_var() and ini_get()

    flconseil@yahoo .fr wrote:[color=blue]
    > Hi,
    >
    > I am writing a PHP library which uses some new configuration options in
    > php.ini. To read the values in my code, I have the choice between
    > get_cfg_var() and ini_get(). From the doc, I thought that they were
    > working almost the same way, except that get_cfg_var() gets its value
    > from the ini file, and ini_get() gives the current value, different if
    > ini_set was called.
    >
    > Actually, when I have this line in php.ini :
    >
    > Autoload.preloa d_include_path = On
    >
    > I get this :
    >
    > get_cfg_var('Au toload.preload_ include_path') = string(1) "1" => OK
    >
    > ini_get('Autolo ad.preload_incl ude_path') = string(0) "" => Strange
    >[color=green]
    > >From the doc again, it means that ini_get() fails.[/color]
    >
    > So, my questions are :
    >
    > - does ini_get() support only PHP predefined configuration options (or
    > configuration options defined by an extension) ?
    > - If it is not the case, why doesn't it read my option ?
    >
    > Thanks in advance
    >
    > François[/color]

    The difference between get_cfg_var() and ini_get() is that the former
    returns whatever is in php.ini while the latter returns the runtime
    settings. Say you stick the following into php.ini:

    [tomkat]
    tomcruise.secre t = "He's gay!"

    get_cfg_var() will happily return the text while ini_get() would not,
    as it's not configurable option belonging to any extension. Or, in
    another word, ini_get() will only return items that are defined in the
    source code.

    Comment

    • flconseil@yahoo.fr

      #3
      Re: Difference between get_cfg_var() and ini_get()

      OK. Thank you for confirming this point.

      Comment

      Working...