[wp-hackers] Variable Scope

Aaron Harun admin at anthologyoi.com
Tue Mar 11 01:47:03 GMT 2008


I don't know exactly when you are trying to call it, but in WP 2.5,
when activating a plugin, you have to declare the variable as a global
outside of a function first.

  global $variable;
  $variable = get_option('variabletest');

  function dummy() {
     global $variable;
     echo $variable;
  }

Aaron.

On 3/10/08, Chris Poteet <cpoteet at siolon.com> wrote:
> I want to have a wider scope for variables in my plugin, but for some
>  reason it's not working.  For instance:
>
>  $variable = get_option('variabletest');
>
>  function dummy() {
>     global $variable;
>     echo $variable;
>  }
>
>  Neither of those work.  Am I doing something wrong (I must be).
>  _______________________________________________
>  wp-hackers mailing list
>  wp-hackers at lists.automattic.com
>  http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list