Jump to content

global $var


yucatan
 Share

Recommended Posts

hi i have a $var and that is used in a func and it get declared in a func so i wanne do add something

global $item += 3

why that dont work

i want in a func to do this

global $item += 3

when i do that i get syntax error

when i do

$item += 3

the $var changes in that func but not in another func..

how i can fix this ?

Link to comment
Share on other sites

If you need your $item variable to be a global one then declare it somewhere inside your main script.

"Global $item" will create the variable in the global scope (know all over the script).

After you create the variable you can increment it, that's why you get an error for "global $item += 3"

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

If you need your $item variable to be a global one then declare it somewhere inside your main script.

"Global $item" will create the variable in the global scope (know all over the script).

After you create the variable you can increment it, that's why you get an error for "global $item += 3"

teh whole func is in a func i cannot run that part in the main script it just cant there got to be a way:S...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...