Jump to content

Does PHP have a 'my' equivalent?


pcw

Recommended Posts

First off PHP has page scope.  That is to say that scripts run, variables are created and when the script finishes everything is disposed of. 

 

Inside a script you can have functions and classes defined.  All variables inside a function or class have local scope.  Additionally variables declared in page scope (globally) are not visible inside class methods or functions.  To use a global you would have to actually declare it as such inside a function, which would then allow the function to access the global variable's value.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.