This question already has answers here:
PHP detect Internet Explorer that is below version 10
(3 answers)
Closed 8 years ago.
The question is, how to detect any IE version using PHP?
I seen PHP scripts that detect specific versions of IE, but I was unable to find a way to detect any version of IE. Thanks for your help.
<?php
function ae_detect_ie()
{
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;
}
?>
taken from : http://www.anyexample.com/programming/php/how_to_detect_internet_explorer_with_php.xml
Related
This question already has answers here:
What is the list of possible values for navigator.platform as of today? [closed]
(3 answers)
Closed 5 years ago.
How to find Windowow devices using Javascript or jquery
use 'navigator.platform' to check what platform you are using.
https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/platform
function isWindows() {
return navigator.platform.indexOf('Win') > -1
}
// Maybe Try this on android deveices
function isAndroid() {
return navigator.platform.indexOf('android') > -1
}
This question already has an answer here:
"Unknown modifier 'g' in..." when using preg_match in PHP?
(1 answer)
Closed 7 years ago.
I have a script I wrote to scan several websites for a google link to make sure it is there. For some reason my script is not working. When I check it at http://www.regexr.com/, it works, but not in live implementation.
example of a link its supposed to find:
https://plus.google.com/+VincentsHeatingPlumbingIncPortHuronTownship/about?hl=en
preg_match I am using:
if (preg_match_all("/(.*)plus.google.com(.*)/", $attributeValue->value))
{
$googleLinkCount ++;
$googleLinkHrefs[] = $attributeValue->value;
}
Don't use a regular expression, use parse_url:
if (parse_url($attributeValue->value, PHP_URL_HOST) === 'plus.google.com') {
// host is plus.google.com
}
This question already has answers here:
PHP: If internet explorer 6, 7, 8 , or 9
(17 answers)
Closed 8 years ago.
How can i detect any-IE in php , if any-ie then continue open page,
else non-ie this page can't open page then show error?
I'm using $_SERVER['HTTP_USER_AGENT'] to detect user's browser..
thx u lot.
$browser = get_browser(null, true);
if($browser['browser'] != 'Internet Explorer') {
die('Only IE');
}
See http://php.net/manual/en/function.get-browser.php
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
PHP startsWith() and endsWith() functions
Check if variable starts with ‘http’
How make an if-statement that if $mystring has the prefix "http://" then {do something}.
I've done this in objective-c like this:
if([mynsstring hasPrefix:#"http://"])
{
//Do something...
}
I don't know how to do this in PHP.
Thanks for your help in advance.
Simplest would be using substring to compare
if (substr($mystring, 0, 7) === 'http://') {
// do something
}
Remember of course to take the exact number of characters.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
My frame is redirecting page !! How to stop it ?
Is there any code like that ?
Please help..Thanks
If you mean a code that detects if it's in a frame, and if so, change the target location?
if (parent.frames.length > 0) parent.location.href = location.href;