Gold Vision Communications / USA
 GOLDVISION.COM
Serving the Multimedia Community since 1989.
English Site | German Site 

 Web Hosting

 Virtual Dedicated Servers

 Chequeo de dominio

 Haga su pedido

 Estado del pedido

 Support

 Contáctenos

 Download

 Network

 Network Status

 Webdesign / Templates

 Efectuar pago

 Terms & Conditions

 Imprimir

 Notas Legales

 Declaración de Privacidad
  PHP / Alternative Syntax für Kontroll-Strukturen
Alternative Syntax für Kontroll-Strukturen

Alternative Syntax für Kontroll-Strukturen

PHP bietet eine alternative Syntax für einige seiner Kontroll-Strukturen, als da sind if, while, for, foreach und switch. Immer muss die öffnende Klammer durch einen Doppelpunkt ":" und die schließende Klammer durch ein endif;, endwhile;, endfor;, endforeach; bzw. endswitch; ersetzt werden.

<?php if ($a == 5): ?>
    A ist gleich 5
<?php endif; ?>

Im obigen Beispiel ist der HTML-Bereich eingebettet in eine if-Anweisung mit alternativer Syntax. Der HTML-Bereich wird nur ausgegeben, wenn $a gleich 5 ist.

Die alternative Syntax kann auch auf else und elseif angewendet werden. Es folgt eine if-Struktur mit elseif und else im alternativen Format:

if ($a == 5):
    print "a ist gleich 5";
    print "...";
elseif ($a == 6):
    print "a ist gleich 6";
    print "!!!";
else:
    print "a ist weder 5 noch 6";
endif;

Siehe auch while, for und if für weitere Beispiele.


© 1998-2007 Gold Vision Communications All Rights Reserved.