Bonjour,
j'essaie d'avoir un bandeau et un style différent selon la connexion de l'utilisateur, seulement j'ai un message d'erreur :
Fatal error: Call to a member function isMobile() on a non-object in configuration.php on line 7...
Merci d'avance.

index.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php session_start();
$nompage = "index.php";
require("configuration.php");
$sql = detection_mobile();
$sql = bandeau_detection();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />	
<title><?php echo $nom_site ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo $nom_style ?>" />
</head>
<body>
<?php include($bandeau); ?> <!-- insère le bandeau principal en haut en fonction de la connexion -->
<div id="mainContent">
<?php require("recherche_pour_news.php"); ?> <!-- insère la recherche des news de la semaine -->
</div>
<?php include('bas_de_page.php'); ?> <!-- insère le bas de page  -->
</body>
</html>
configuration.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
....
 
// pour detecter les smartphones et utiliser le bon style CSS...
include("Mobile_Detect.php");
$detect = new Mobile_Detect();
function detection_mobile()
{
	if ($detect->isMobile())
	{
		echo '<br/>';
		echo 'vous etes sur le site mobile : ';
		echo '<br/>';
		echo $_SERVER['HTTP_USER_AGENT']; 
		echo '<br/>';
		$nom_style = "style_mobile.css";
		echo 'nom style :'.$nom_style;
		echo '<br/>';
		$bandeau_non_connecte = "bandeau_mobile.php";
		$bandeau_connecte = "bandeau_membres_mobile.php";
	}
	else
	{
		echo '<br/>';
		echo 'vous etes sur le site classique : ';
		echo '<br/>';
		echo $_SERVER['HTTP_USER_AGENT'];
		echo '<br/>';
		$nom_style = "style.css"; 
		echo 'nom style :'.$nom_style; 
		echo '<br/>';
		$bandeau_non_connecte = "bandeau.php";
		$bandeau_connecte = "bandeau_membres.php";
	}
}
 
function bandeau_detection() 	// si l'utilisateur est connecté, c'est le bandeau membre sinon c'est le bandeau classique...
	{
		if (!isset($_SESSION['pseudo']) || $_SESSION['pseudo']=='')	// bandeau classique si pas connecté
		{ $bandeau = $bandeau_non_connecte;	}
		else 	// bandeau membre si connecté
		{ $bandeau = $bandeau_connecte;	} 
	}
 
 
function connect_sql() 		//Connection à MySQL
{
	global $sql_serveur, $sql_login, $sql_pass, $sql_bdd;
	//connexion au serveur
	$linkid = @mysql_connect($sql_serveur,$sql_login,$sql_pass) or die ("Erreur lors de la connection au serveur MySQL !");
	//selection de la BDD
	@mysql_select_db($sql_bdd,$linkid) or die("Impossible de selectionner la base de données\n<br>\nVoici l'erreur renvoyée par le serveur MySQL :\n<br>\n".mysql_error());
	return $linkid;
}
?>
Mobile_Detect.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
 * Mobile Detect
 *
 * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version    SVN: $Id: Mobile_Detect.php 4 2011-05-26 08:04:20Z vic.stanciu@gmail.com $
 */
class Mobile_Detect 
{	protected $accept;
    protected $userAgent;
    protected $isMobile     = false;
    protected $isAndroid    = null;
    protected $isBlackberry = null;
    protected $isOpera      = null;
    protected $isPalm       = null;
    protected $isWindows    = null;
    protected $isGeneric    = null;
    protected $devices = array
	(
        "android"       => "android",
			/* "firefox"       => "firefox",  */  ///* pour TEST SUR PC */// 
        "blackberry"    => "blackberry",
        "iphone"        => "(iphone|ipod)",
        "opera"         => "opera mini",
        "palm"          => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)",
        "windows"       => "windows ce; (iemobile|ppc|smartphone)",
        "generic"       => "(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap)"
    );
 
	public function __construct() 
	{
		$this->userAgent = $_SERVER['HTTP_USER_AGENT'];
        $this->accept    = $_SERVER['HTTP_ACCEPT'];
        if (isset($_SERVER['HTTP_X_WAP_PROFILE'])|| isset($_SERVER['HTTP_PROFILE'])) 
			{
				$this->isMobile = true;
			} 
		elseif (strpos($this->accept,'text/vnd.wap.wml') > 0 || strpos($this->accept,'application/vnd.wap.xhtml+xml') > 0) 
			{
				$this->isMobile = true;
			}
			else 
			{
				foreach ($this->devices as $device => $regexp) 
				{
					if ($this->isDevice($device)) 
					{
						$this->isMobile = true;
					}
				}
			}
	}
 
	/**
	* Overloads isAndroid() | isBlackberry() | isOpera() | isPalm() | isWindows() | isGeneric() through isDevice()
     *
     * @param string $name
     * @param array $arguments
     * @return bool
     */
    public function __call($name, $arguments) 
	{
        $device = substr($name, 2);
        if ($name == "is" . ucfirst($device)) 
		{
            return $this->isDevice($device);
        }
		else
		{
            trigger_error("Method $name not defined", E_USER_ERROR);
        }
    }
 
	/**
	* Returns true if any type of mobile device detected, including special ones
     * @return bool
     */
    public function isMobile() 
	{
        return $this->isMobile;
    }
 
    protected function isDevice($device) 
	{
        $var    = "is" . ucfirst($device);
        $return = $this->$var === null ? (bool) preg_match("/" . $this->devices[$device] . "/i", $this->userAgent) : $this->$var;
		if ($device != 'generic' && $return == true) 
			{
				$this->isGeneric = false;
			}
        return $return;
    }
}
?>