Question

I want to create a file-static variable in PHP. How can I do this or what should I use instead?

Edit:

I'm basically wanting to create a file-scope static variable, similar to what is available in C/C++.

Was it helpful?

Solution 2

After further investigation, it seems like the easiest solution is to just use a class which wraps the functions. The only downside is you have to use the prefix when calling: Container::Func(); This could be solved with an additional wrapper for each function, but this isn't as clean of a solution.

OTHER TIPS

You can take a look at namespaces. Available only in PHP >=5.3 http://www.php.net/manual/en/language.namespaces.rationale.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top