Basic PHP if logic for multiple statements -


i want include addtohomescreen.php in page following conditions:

  1. $ua !== 'sattamatka.pro' -> true
  2. $ua !== 'sattamatka.android' -> true
  3. stripos($ua,'android') == true) -> true

i using following logic:

<?php if($ua !== 'sattamatka.pro'  || $ua !== 'sattamatka.android'  && stripos($ua,'android') == true) { include "addtohomescreen.php"; } ?> 

note: want of them true. if use && in place of || both of statements - $ua !== 'sattamatka.pro' , $ua !== 'sattamatka.android' becomes false , addtohomescreen.php included in both $ua.

edit: possible vales of $ua are:

  1. sattamatka.pro
  2. sattamatka.android
  3. mozilla/5.0 (linux; u; android 6.0.1; en-us; redmi note 3 build/mmb29m) applewebkit/534.30 (khtml, gecko) version/4.0 ucbrowser/11.2.5.932 u3/0.8.0 mobile safari/534.30

update: problem $ua = 'sattamatka.pro' , $ua = 'sattamatka.android' statement if(($ua !== 'sattamatka.pro') && ($ua !== 'sattamatka.android') && (stripos($ua,'android') == true)) returned false. has been solved adding () ($ua !== 'sattamatka.pro') || ($ua !== 'sattamatka.android') & code works expected. don't need more suggestions. thank time.

you need use && if want condition become true

if(($ua !== 'sattamatka.pro') && ($ua !== 'sattamatka.android') && (stripos($ua,'android') == true)) { include "addtohomescreen.php"; } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -