In php, how to ensure that another function must be called before a function is called. Of course, we may soon think of class constructors and member functions. Are there other methods besides this? Suppose you must call the Init function before calling Search. you can use the following method to group... SyntaxHighlighter. all ();
In php, how to ensure that another function must be called before a function is called. Of course, we may soon think of class constructors and member functions. Are there other methods besides this?
Assume that you must call the Init function before calling Search. the code can be organized as follows:
[Php] function Init (){
// Init implementation
// To do init
// Search implementation
// To do search
Function Search (){
}
}
Function Init (){
// Init implementation
// To do init
// Search implementation
// To do search
Function Search (){
}
}
In this way, you must call Init before calling the function Search. Otherwise, an error is reported!
For other details, see: http://cn2.php.net/manual/en/language.functions.php
From the pure soul