The function returns null
-
Hello, there's a problem, a function returns null. Synthaxis seems to be fine, looking at PHP's check--- it's okay, I don't understand why.
Part of the code with function:
function SearchWord($query) { $find = "club"; $search = strpos($query, $find); return $search; }
SearchWord($getData['response']['items'][$i]['text']);
if($search == true) {
echo "Get Word<br>";
}
If you need to, I'll send the whole code. Maybe this variable can't be returned?
P.S. I've been checking my point in the function, it's okay. Checking if he's coming back.
strpos()
true/false inside the function itself - yes, returning.
-
To benefit from the function
SearchWord()
It's gonna have to be recorded in the variable.$search
because$search
inside functionSearchWord()
and out of it are different variables.function SearchWord($query){ $find = "club"; $search = strpos($query, $find); return $search; }
$search = SearchWord($getData['response']['items'][$i]['text']);
if($search == true){
echo "Get Word<br>";
}
In your version, the violin will work if inside the function.
SearchWord()
declare the variable$search
Globalfunction SearchWord($query){
global $search;
$find = "club";
$search = strpos($query, $find);
return $search;
}
However, a better avoidance of such practices is a bad tone that leads to many problems, especially if the annex grows and becomes large.