Welcome Guest, Not a member yet? Register   Sign In
How to call a variable globally
#3

[eluser]thurting[/eluser]
I don't really know what you are trying to accomplish with that class, but it doesn't look like it should be a subclass of Controller. In any case, if you want to define a global constant you should check out the define() function which is native to PHP. You could also define your global variables as static properties of a class. I would suggest coding in PHP5 if you were going to go this route. For example, you could create a class (GlobalSettings) with a static property (db) and access it via GlobalSettings::db. Depending on your application, you may want to make that class a singleton. You could also store your variables in SESSION, but you probably wouldn't want to do that.


Messages In This Thread
How to call a variable globally - by El Forum - 10-21-2007, 11:02 PM
How to call a variable globally - by El Forum - 10-21-2007, 11:56 PM
How to call a variable globally - by El Forum - 10-21-2007, 11:59 PM
How to call a variable globally - by El Forum - 10-22-2007, 12:11 AM
How to call a variable globally - by El Forum - 10-22-2007, 12:39 AM
How to call a variable globally - by El Forum - 10-22-2007, 12:47 AM
How to call a variable globally - by El Forum - 10-22-2007, 12:49 AM
How to call a variable globally - by El Forum - 10-22-2007, 12:52 AM
How to call a variable globally - by El Forum - 10-22-2007, 01:13 AM
How to call a variable globally - by El Forum - 10-22-2007, 02:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB