IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Problème SWITCH PHP [PHP 5.2]


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Étudiant
    Inscrit en
    Septembre 2008
    Messages
    60
    Détails du profil
    Informations personnelles :
    Âge : 36

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2008
    Messages : 60
    Points : 32
    Points
    32
    Par défaut Problème SWITCH PHP
    Bonjour,

    J'ai un souci dans un script content un switch. Voici le code :

    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
     
    <?php
    switch($_GET['page'])
    {
    case 'news':
    echo ' ';
    break;
     
    case 'articles_index' || 'articles' || 'articles_xp' || 'articles_vista' || 'articles_7' || 'articles_office' || 'articles_dev':
    echo ('<div id="menu_articles_content">
    		<!-- Contenu du Menu -->
    		<!-- Articles --><a href="index2.php?page=articles_index"><img src="Images/ArticlesTag.png" alt="Articles"/></a>
    		<b>
    		<ul>
    			<li><a href="index2.php?page=articles_xp">Microsoft Windows XP</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_vista">Microsoft Windows Vista</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_7">Microsoft Windows 7</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_office">Microsoft Office</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_dev">Web Developement</a></li>
    		</ul>
    		</b>
    	  </div>');
    break;
     
    case 'tutoriaux_index' || 'tutoriaux' || 'tutoriaux_xp' || 'tutoriaux_vista' || 'tutoriaux_7' || 'tutoriaux_office' || 'tutoriaux_dev':
    echo ('<div id="menu_tutoriaux_content">
    		<!-- Contenu du Menu -->
    		<!-- Tutoriaux --><a href="index2.php?page=tutoriaux_index"><img src="Images/TutoriauxTag.png" alt="Tutoriaux"/></a>
    		<b>
    		<ul>
    			<li><a href="index2.php?page=tutoriaux_xp">Microsoft Windows XP</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_vista">Microsoft Windows Vista</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_7">Microsoft Windows 7</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_office">Microsoft Office</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_dev">Web Developement</a></li>
    		</ul>
    		</b>
    	  </div>');
    break;
     
    default:
    echo ' ';
    break;
    ?>
    Le premier et le deuxième case fonctionnent bien, ce qui n'est pas le cas du troisième. Je ne vois pas du tout d'où peut venir ce problème. Par contre si je met le troisième case en premier, là encore seul le premier et le deuxième case marche (c'est-à-dire le troisième case que j'ai mis au début + le case 'news').

    Si quelqu'un peut m'aider.

    Merci

    Srini

  2. #2
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2007
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juin 2007
    Messages : 148
    Points : 186
    Points
    186
    Par défaut
    Bonjour,

    Sauf si je me trompe il n'y a pas de condition dans le switch, essai ceci.

    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
     
    <?php
    switch($_GET['page'])
    {
    case 'news':
    echo ' ';
    break;
     
     
    case 'articles_index':
    case 'articles':
    case 'articles_xp':
    case 'articles_vista':
    case 'articles_7':
    case 'articles_office':
    case 'articles_dev':
    echo ('<div id="menu_articles_content">
    		<!-- Contenu du Menu -->
    		<!-- Articles --><a href="index2.php?page=articles_index"><img src="Images/ArticlesTag.png" alt="Articles"/></a>
    		<b>
    		<ul>
    			<li><a href="index2.php?page=articles_xp">Microsoft Windows XP</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_vista">Microsoft Windows Vista</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_7">Microsoft Windows 7</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_office">Microsoft Office</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=articles_dev">Web Developement</a></li>
    		</ul>
    		</b>
    	  </div>');
    break;
     
     
    case 'tutoriaux_index':
    case 'tutoriaux':
    case 'tutoriaux_xp':
    case 'tutoriaux_vista':
    case 'tutoriaux_7':
    case 'tutoriaux_office':
    case 'tutoriaux_dev':
    echo ('<div id="menu_tutoriaux_content">
    		<!-- Contenu du Menu -->
    		<!-- Tutoriaux --><a href="index2.php?page=tutoriaux_index"><img src="Images/TutoriauxTag.png" alt="Tutoriaux"/></a>
    		<b>
    		<ul>
    			<li><a href="index2.php?page=tutoriaux_xp">Microsoft Windows XP</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_vista">Microsoft Windows Vista</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_7">Microsoft Windows 7</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_office">Microsoft Office</a></li><br />
    			<!--[if IE]>
    				<br />
    			<![endif]-->
    			<li><a href="index2.php?page=tutoriaux_dev">Web Developement</a></li>
    		</ul>
    		</b>
    	  </div>');
    break;
     
    default:
    echo ' ';
    break;
    ?>
    GoT

  3. #3
    Nouveau membre du Club
    Étudiant
    Inscrit en
    Septembre 2008
    Messages
    60
    Détails du profil
    Informations personnelles :
    Âge : 36

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2008
    Messages : 60
    Points : 32
    Points
    32
    Par défaut Ca marche
    Salut,

    Merci beaucoup ça marche. Tu avais raison, pas de condition dans un switch.

    Srini

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. PHP Problème Switch
    Par snaxisnake dans le forum Langage
    Réponses: 11
    Dernier message: 28/11/2007, 01h11
  2. [XML] Problème XMLHttpRequest / PHP
    Par ldcarpathes dans le forum Bibliothèques et frameworks
    Réponses: 5
    Dernier message: 26/04/2006, 15h05
  3. Problème entre php et mysql
    Par kornmuse90 dans le forum Apache
    Réponses: 17
    Dernier message: 24/04/2006, 15h52
  4. [PHP-JS] Problème en PHP
    Par chouchou23 dans le forum Langage
    Réponses: 12
    Dernier message: 18/04/2006, 11h27
  5. Problème : Script PHP IE NOK Firefox OK
    Par Saiyan dans le forum Langage
    Réponses: 40
    Dernier message: 15/11/2005, 23h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo