文字列の結合
■ 文字列の結合
JavaScriptなどでは、複数の文字列を「+」で結合することができますが、PHPでは「+」ではなくて「.」という演算子を使います。 結合演算子は代入演算子と複合することもできます。 $str = "あい"; $str .= "うえお"; print $str; //「あいうえお」と表示される <?php $a = "Hello,"; $b = "World";// header("Content-Type: text/plain; charset=EUC-JP"); echo $a . $b; //文字列を連結 ?>
JavaScriptなどでは、複数の文字列を「+」で結合することができますが、PHPでは「+」ではなくて「.」という演算子を使います。 結合演算子は代入演算子と複合することもできます。
$str = "あい"; $str .= "うえお"; print $str; //「あいうえお」と表示される <?php $a = "Hello,"; $b = "World";// header("Content-Type: text/plain; charset=EUC-JP"); echo $a . $b; //文字列を連結 ?>
$str = "あい"; $str .= "うえお"; print $str; //「あいうえお」と表示される
<?php $a = "Hello,"; $b = "World";// header("Content-Type: text/plain; charset=EUC-JP"); echo $a . $b; //文字列を連結 ?>
<<戻る