<?php $a = "Hello"; echo $a . " world!"; /* 《程式語言教學誌》的範例程式 http://pydoing.blogspot.com/ 檔名:e19.php 功能:示範 PHP 程式 作者:張凱慶 時間:西元 2013 年 2 月 */ ?>
小數點放在變數 (variable) 與變數或變數與字串之間就會自動連接
echo $a . " world!";
執行結果如下

字串運算子也可以與指派運算子 (assignment operator) 連用,例如
<?php $a = "Hello"; $a .= " world!"; echo $a; /* 《程式語言教學誌》的範例程式 http://pydoing.blogspot.com/ 檔名:e20.php 功能:示範 PHP 程式 作者:張凱慶 時間:西元 2013 年 2 月 */ ?>
執行結果如下

中英文術語對照 | |
---|---|
字串運算子 | string operator |
字串 | string |
變數 | variable |
指派運算子 | assignment operator |
您可以繼續參考
運算式
相關目錄
回 PHP 快速導覽
回 PHP 教材
回首頁
參考資料
http://www.php.net/manual/en/language.operators.string.php
沒有留言:
張貼留言