سؤال

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++.

هل كانت مفيدة؟

المحلول 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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top