jrmy7
Messages postés14Date d'inscriptionsamedi 10 octobre 2009StatutMembreDernière intervention22 mai 2012
-
28 nov. 2011 à 15:59
jrmy7
Messages postés14Date d'inscriptionsamedi 10 octobre 2009StatutMembreDernière intervention22 mai 2012
-
28 nov. 2011 à 19:22
Bonjour à tous !
Voilà j'ai était obligé de passer en PHP5 si pour mettre du xml à jour avec du php en utiisant le DOM.
Mais depuis j'ai un problème avec un script PHP servant à rediriger le visiteur selon s'il utilise un "Smartphone" ou un ordinateur (le script ne redirige plus lorsque l'on y va avec un ordi :cry:).
Voilà le script utilisé (qui fonctionne très bien en PHP4 !) :
<?php
if(checkmobile())
header('Location:http://www.eternal-graphic.com/mobile/m_detect_lang.php');
function checkmobile()
{
if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']))
return true;
if (isset ($_SERVER['HTTP_ACCEPT']))
{
$accept = strtolower($_SERVER['HTTP_ACCEPT']);
if (strpos($accept, 'wap') !== false)
return true;
}
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
if (strpos ($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false)
return true;
if (strpos ($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false)
return true;
if (preg_match('#Android|BlackBerry|Cellphone|iPhone|iPod|hiptop|HTC|MIDP-2\.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nintendo DS|Nitro|Nokia|Opera Mobi|Palm|PlayStation Portable|PSP|portalmmm|SonyEricsson|Symbian|UP.Browser|UP.Link|webOS|Windows CE|WinWAP|YahooSeeker/M1A1-R2D2|LGE VX|Maemo|phone)#', $_SERVER['HTTP_USER_AGENT']))
return true;
}
header('Location: http://www.eternal-graphic.com/computer ... _lang.php');
}
?>
Voilà le msg sur la page :
[b]
Warning: preg_match() [function.preg-match]: Compilation failed: unmatched parentheses at offset 280 in /homepages/39/d299682238/htdocs/eternal-graphic/index.php on line 26
Warning: Cannot modify header information - headers already sent by (output started at /homepages/39/d299682238/htdocs/eternal-graphic/index.php:26) in /homepages/39/d299682238/htdocs/eternal-graphic/index.php on line 30/b
cs_47
Messages postés197Date d'inscriptionmardi 20 janvier 2004StatutMembreDernière intervention20 février 20131 28 nov. 2011 à 16:11
Bonjour,
d'après le message d'erreur, les parenthèses ne sont pas équilibrés, entre autre dans ton expression, il y a une parenthèse fermante, mais pas d'ouvrante.
TychoBrahe
Messages postés1309Date d'inscriptionsamedi 31 janvier 2009StatutMembreDernière intervention 5 juin 201312 28 nov. 2011 à 16:43
Salut,
47 à tout à fait raison, il manque une parenthèse ouvrant dans ta regexp. C'est une erreur que ça ai fonctionné en php4, ça n'aurais jamais du être le cas.