I have a function to run a query from database. Then, it will be called by 2 other functions.
function query(){
$query= // get data from database;
return $query;
}
function show_something(){
$data = query();
//do something
}
function show_else(){
$data = query();
//do something else
}
The function query() is called twice. I guess it would do the query job every time the function is called unless the result is cached. Would anybody correct me if I am wrong?
You could simply do something like this:
Code: