PHP逆引き大全 516の極意

基本プログラミングの極意 - Tips96 文字列を出力する

登録タグ
PHP
Icon comment count 0
Icon stock count 0

1-4文字列Tips96 文字列を出力する

Level1

Pointecho文、print文を使う

文字列を出力するには、echo文print文を使います。

echo文は複数の文字列を一度に出力し、print文は1つの文字列のみ出力します。

echo文やprint文は関数ではないため、引数に括弧をつける必要はありません。

echo文とprint文の使い方

echo 文字列1, 文字列2 ...;
print 文字列1;
リスト1096.php
<?php
  header("Content-Type: text/plain; charset=UTF-8");
  echo "echo文\n", "あいうえお", "\n";
  print "print文\nあいうえお\n";
?>
画面1 実行画面(096.php)

出典情報

Medium

PHP逆引き大全 516の極意

  • 著者: 大家 正登, 茂木 健一, 鮫島 康浩, 谷中 志織

コメント

    コメントはありません