Jump to content

Howto use global variables

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
How do I use global variables such as $_POST????

Here is an example:


$variable = "some text";


function myfunc() {

   print $variable; // Does not work

}



#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
$variable = "some text";


function myfunc() {

   global $variable;

   print $variable; // Does not work

} 

that sould do the trick :)

#3
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
I was having the same problem and was about to post a topic.
That works.

Thank you Sidewinder

#4
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
Thanks, stupid thing is I knew that already......

#5
Guest_bernkly_*

Guest_bernkly_*
  • Guests
Global variables. Just declare it outside of a local method. This is applied for other computer languages too.

But it's not a programming wise in such way.