Warning: Undefined array key 0 in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/functions.php on line 406

Warning: Attempt to read property "parent" on null in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/functions.php on line 407

Warning: Attempt to read property "term_id" on null in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/functions.php on line 413

Warning: Attempt to read property "cat_name" on null in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/functions.php on line 413

テキスト出力のサンプル

PHP

テキストを出力するechoを使って、簡単なPHPのサンプルを書いてみます。

下記はHTML文書内に「Hello world!!」を3回出力するものです。 一つはHTMLで、残りはPHPの構造言語であるechoで出力します。echoはクォーテーション内の文字をそのまま出力するものです。


  <title>echo sample</title>

  
<p>Hello world!!</p>
<?PHP echo "<p>Hello world!!</p>"; ?>
<?PHP 
  echo "<p>";
  echo "Hello world!!";
  echo "</p>";
?>
  

この処理結果は、どれも同じように「Hello world!!」を出力します。

出力結果

ello world!!
Hello world!!
Hello world!!

HTMLソース全ての記述をPHPで出力することも可能です。 ちょっと込み入った処理になると、一行に何度もスクリプト宣言を行う事もあります。

lt;?PHP 
  echo "n";
  echo "n";
  echo "<title>test</title>n";
  echo "n";
  echo "n";
  echo "<p>Hello world!!</p>n";
  echo "n";
  echo "n";
?>


<title>test</title>


<p>hellow world!!</p>


出力結果

ello world!!

HTML部はスクリプト宣言外で記述するのが一般的とですが、好みの問題でもあるので自分が書きやすいように工夫してコーディングしましょう。


Warning: Undefined variable $category in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/content.php on line 79

Warning: Attempt to read property "name" on null in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/content.php on line 79

の記事

eyecatch

ウェブ特有のライティング作法「ウェブライティング」入門

eyecatch

JavaScriptの正規表現

eyecatch

HTML文書の記述ルールと作法

eyecatch

演算と演算子

eyecatch

CSSとは

eyecatch

XAMPPをアンインストールする方法


Warning: Undefined variable $category in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/content.php on line 84

Warning: Attempt to read property "count" on null in /home/yatsuba/yatsuba.com/public_html/wp-content/themes/amaru/content.php on line 84
HOME