lundi 1 juin 2015

Running code in a PHP once

I'm trying to write a class in PHP that acts as a wrapper for a collection of command line tools to make them easier to use from PHP.

I have a single class (MyClass) in a file myclass.php.

I have code that checks to see if the required tools are installed and then sets a constant (TOOLS_AVAILABLE) to either true or false. Although it's not a lot of code, I only want it to run the first time somebody tries to instantiate my class. What's the best practice for handling this?

Aucun commentaire:

Enregistrer un commentaire