using function strpos in PHP -


i need create function in php can read , save in variable 2 characters (@) , (a) of txt file, txt:

trying 192.168.25.200... connected 192.168.25.200. escape character '^]'. *hello*^@^a 

my code:

<?php if(isset($_post['estado'])) { exec('/var/www/www.rfteste.com/htdocs/estado.sh'); }  if(isset($_post['ligar'])) { exec('/var/www/www.rfteste.com/htdocs/liga.sh'); }  if(isset($_post['desligar'])) { exec('/var/www/www.rfteste.com/htdocs/desliga.sh'); }  echo "<h3>controle de iluminacao</h3>";  $str = file_get_contents("/var/www/www.rfteste.com/htdocs/estado.txt"); $word = "/@/"; if(strpos($str, $word) !== true) { echo "ligado"; echo "$str"; } ?> <html> <body> <form method="post" action=""> <p> <center><input type="submit" value="ligar" name="ligar""';" /></center> <center><input type="submit" value="desligar" name="desligar""';" /></center> <center><input type="submit" value="atualizar" name="estado""';" /></center>   </p> </form> </body> 

according reference strpos function returns position of in haystack string or false if needle not found.

you (comparison strpos($str, $word) !== true) not correct. must write strpos($str, $word) === false


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -