In php, how to ensure that before calling a function, another function must be called. Of course, we may soon think of class constructors and member functions. Is there any other way besides this way?
Assume that before calling Search, the Init function must be called. The code can be organized as follows:
[php] function Init(){
//Implementation of init itself
// to do init
//Implementation of Search
// to do search
Function Search(){
}
}
function Init(){
//Implementation of init itself
// to do init
//Search implementation
// to do search
function Search(){
}
}
In this way, when calling the function Search, Init must be called first. Otherwise, an error will be reported!
For other details, please refer to: http://cn2.php.net/manual/en/language.functions.php
Excerpted from The Pure Land of the Soul