Welcome Guest, Not a member yet? Register   Sign In
using global variable or method within one class,
#3

[eluser]esra[/eluser]
[quote author="Jim OHalloran" date="1189400360"]If you're using PHP 5, you can change the "var" in front of those variables to "public" or "private" and control the visibility of those variables. "public" makes those variables available to other users of the class, while "private" limits their visibility to functions within the class. The PHP manual has some more information on visibility which might be of assistance if you're using PHP5.

Jim.[/quote]

There is also 'protected' which restricts visibility to classes extended from a parent class. That is, the variable would have private visibility to any class that was not extended from a parent class.

In a language like C++, private and protected members are deemed read-only but this not the case with PHP5, but it's supposed to be fixed in PHP6. However, there is a class on phpclasses.org that does make private and protected members read-only.


Messages In This Thread
using global variable or method within one class, - by El Forum - 09-09-2007, 01:20 AM
using global variable or method within one class, - by El Forum - 09-09-2007, 05:59 PM
using global variable or method within one class, - by El Forum - 09-09-2007, 08:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB