Is it possible to use the LIKE statement which in mysql queries, for something else, for example, in order to simply compare the variables. Tipo:
if (q LIKE a) { echo 'good'; } Operators from SQL to PHP cannot be used.
PHP has its own operators. Instead of LIKE, you can use strpos() .
In php, their operators are enough for comparison, sampling, conditional statements, database connectors, etc.
$a = 'How are you?'; if (\strpos($a, 'are') !== false) { echo 'true'; } Written from a mobile, sorry :)
Well, if you want so, you can come up with a function of the form:
function LIKE($a,$b){ $res=false; if (strpos($a, $b) !== false) {$res=true;} return $res; }; if (LIKE("aaa","a")) echo "TRUE"; ;)
Source: https://ru.stackoverflow.com/questions/938287/
All Articles
LIKE? Give examples. But I don’t understand true LIKE 'true' or not - ArchDemon 5:06mysql_qiery("SELECT '$q' LIKE '$a%' AS result;"likemysql_qiery("SELECT '$q' LIKE '$a%' AS result;"and check whether the result is TRUE - but this is completely beyond reasonable ... - Akina