Is my syntax for checking multiple strings (existing of one of both strings) in a user agent correct?
I mean the part 'google|lighthouse'
. If not, what should be the correct kind of writing?
<?php if (!isset($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'google|lighthouse') === false): ?>
// code
<?php endif; ?>
2
Answers
I think you are not doing what you want to do. you are search for string ‘google|lighthouse’ inside the $_SERVER[‘HTTP_USER_AGENT’], I guess you want something like
You need to use regular expression for that, otherwise you are just looking for literal sequence of
google|lighthouse
: