global

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mark

    global

    Hi, I have the following code...

    ############### ###
    $myvar = "test";

    function myfunc() {
    global $myvar;
    echo $myvar;
    }
    ############### ###

    However, when echoing $myvar it is blank. Can anybody tell me what I am
    doing wrong?
  • Andy Hassall

    #2
    Re: global

    On Wed, 29 Jun 2005 20:35:18 +0000 (UTC), mark <mark@something .com> wrote:
    [color=blue]
    >$myvar = "test";
    >
    >function myfunc() {
    >global $myvar;
    >echo $myvar;
    >}
    >
    >However, when echoing $myvar it is blank. Can anybody tell me what I am
    >doing wrong?[/color]

    Post a runnable piece of code that demonstrates the problem - the one you just
    posted does not call the function.

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • mark

      #3
      Re: global

      Thanks Andy, I was preparing a runable piece of code to post and came
      across the problem! I changed a variable name in an include file which
      was causing the problem. Need some sleep!

      Cheers.


      Andy Hassall wrote:[color=blue]
      > On Wed, 29 Jun 2005 20:35:18 +0000 (UTC), mark <mark@something .com> wrote:
      >
      >[color=green]
      >>$myvar = "test";
      >>
      >>function myfunc() {
      >>global $myvar;
      >>echo $myvar;
      >>}
      >>
      >>However, when echoing $myvar it is blank. Can anybody tell me what I am
      >>doing wrong?[/color]
      >
      >
      > Post a runnable piece of code that demonstrates the problem - the one you just
      > posted does not call the function.
      >[/color]

      Comment

      Working...