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'; } 
  • What do you mean by LIKE ? Give examples. But I don’t understand true LIKE 'true' or not - ArchDemon 5:06
  • one
    Formally, you can, of course, portray a thread of mysql_qiery("SELECT '$q' LIKE '$a%' AS result;" like mysql_qiery("SELECT '$q' LIKE '$a%' AS result;" and check whether the result is TRUE - but this is completely beyond reasonable ... - Akina

3 answers 3

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"; 

      ;)