Problème de compatibilité PHP4 / PHP5 !

jrmy7 Messages postés 14 Date d'inscription samedi 10 octobre 2009 Statut Membre Dernière intervention 22 mai 2012 - 28 nov. 2011 à 15:59
jrmy7 Messages postés 14 Date d'inscription samedi 10 octobre 2009 Statut Membre Dernière intervention 22 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

...pour voir de vous même : http://www.eternal-graphic.com



[b]
Un grand merc/b
i d'avance à ceux qui pourront m'aider !

...

4 réponses

cs_47 Messages postés 197 Date d'inscription mardi 20 janvier 2004 Statut Membre Dernière intervention 20 février 2013 1
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.

bonne après midi
0
jrmy7 Messages postés 14 Date d'inscription samedi 10 octobre 2009 Statut Membre Dernière intervention 22 mai 2012
28 nov. 2011 à 16:16
J'ai déjà vérifié ça... et ce script marche très bien avec PHP4 !

Mais merci quand même...
0
TychoBrahe Messages postés 1309 Date d'inscription samedi 31 janvier 2009 Statut Membre Dernière intervention 5 juin 2013 12
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.
0
jrmy7 Messages postés 14 Date d'inscription samedi 10 octobre 2009 Statut Membre Dernière intervention 22 mai 2012
28 nov. 2011 à 19:22
Je suis vraiment étourdie....

Mais c'est vrai que je ne comprend comment ça fonctionné en PHP4 ???

En tout cas MERCI , ça marche très bien maintenant.
0
Rejoignez-nous