Pourquoi goto ne fonctionne pas sur php

Résolu
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 - 7 juin 2010 à 18:01
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 - 10 juin 2010 à 11:13
bonjour

je me demande pourquoi goto ne fonctionne pas sur PHP j'utilise la vesion 5.3


Article sur manuel php.net
http://php.net/manual/fr/control-structures.goto.php

4 réponses

TychoBrahe Messages postés 1309 Date d'inscription samedi 31 janvier 2009 Statut Membre Dernière intervention 5 juin 2013 12
8 juin 2010 à 12:39
Erf, mon code php est passé à la trape quand j'ai posté le message... saleté de parseur <_<

Je remet donc ici mon shell :
tycho@uraniborg-> php --version
PHP 5.3.2-1 with Suhosin-Patch (cli) (built: Mar 13 2010 22:18:25) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbH
tycho@uraniborg-> cat plop.php 
<?php

goto toto;
die("failed\n");
toto:
echo 'success', "\n";

?>
tycho@uraniborg-> php plop.php 
success
tycho@uraniborg-> 
3
TychoBrahe Messages postés 1309 Date d'inscription samedi 31 janvier 2009 Statut Membre Dernière intervention 5 juin 2013 12
8 juin 2010 à 12:36
Salut,

tycho@uraniborg-> php --version
PHP 5.3.2-1 with Suhosin-Patch (cli) (built: Mar 13 2010 22:18:25) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbH
tycho@uraniborg-> cat plop.php 
<?php

goto a;
die("failed\n");

a:
echo 'it works', "\n";

?>
tycho@uraniborg-> php plop.php
it works
tycho@uraniborg-> 

Et bien ça fonctionne très bien les goto en php 5.3, aucun problème. Cependant, il serait préférable que ça ne fonctionne pas : les goto sont une hérésie à bannir. Attention ! Edsger Dijkstra te regarde !
0
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 1
10 juin 2010 à 11:12
bizzare ton scripte fonctionne en tout cas merci
0
jihednond Messages postés 143 Date d'inscription jeudi 27 mars 2008 Statut Membre Dernière intervention 3 septembre 2011 1
10 juin 2010 à 11:13
peut être que que le script a eu peur de Edsger Dijkstra ..
0
Rejoignez-nous