1

I have this error while I'm using this my script:

$pages = array('/about.php', '/');

//...............function text here................//

$ua = $_SERVER['HTTP_USER_AGENT'];
$mobiles = '/iphone|ipad|android|symbian|BlackBerry|HTC|iPod|IEMobile|Opera Mini|Opera Mobi|WinPhone7|Nokia|samsung|LG/i';

if (preg_match($mobiles, $ua)) {
  $thispage = $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];

if ($thispage == $_SERVER["HTTP_HOST"].$pages) {
     ob_start("text");
}
}

This script changes certain pages style depending on user's useragent. I need this script in such way. But I don't know how to make it in PHP properly. Maybe I need some "foreach ($pages as $i)"? But it didn't work in a way I made it.

1 Answer 1

1

You are trying to check if the "requested resource" $_SERVER["REQUEST_URI"] is in predefined list of resource paths.
Change your condition as shown below(using in_array function):

...
if (in_array($_SERVER["REQUEST_URI"], $pages)) {
     ob_start("text");
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very mega much! =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.