LoginSignup
2
2

More than 5 years have passed since last update.

【PHP】代替構文(endswitch文)

Last updated at Posted at 2013-12-24

こんにちは。
どうしても頭に代替構文が入ってこないので、メモ。

<?php
$i = 1 ;

switch($i) :
    case 0 :
        echo "テスト" ;
        break ;

    case 1 : 
        echo "テスト1" ;
        break ;

    default :
        echo "default" ;
endswitch ; ?>

おそらく実用的な使い方は、

<?php    switch($i)    ?>
<?php    case 1:   ?>
<?php    break;?>
<?php    endswitch ; ?>

みたく1行ずつ記載していくんだと思う。
短くて見やすさを強くするため?

if文でもいきなり

<?php if ($a == 5): ?>
~~
<?php endif ; ?>

と出てくると難しく思えてしまう。
実際はもっと多用されているだろうから、なれなくては。

それではこれからも宜しくお願いいたします。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2