作者picachuxyz (XHTML&CSS&JS&PHP)
看板PHP
標題Re: [請益] heredoc synex 在php5裡有支援嗎?
時間Fri Jan 20 16:59:03 2006
※ 引述《johnney (You make me Complete!)》之銘言:
: <?php
: echo <<<heredoc
: 測試<br>
: 測試0
: heredoc; // 前面不能有任何字元
: ?>
請問如果裡面夾雜函數和陣列怎麼寫?
ex1:
echo <<<heredoc
<h1>htmlspecialchars($row["subject"])</h1>
heredoc; //ex1會有錯誤
如果$a=$row["subject"]; //if $a='123'
ex2:
echo <<<heredoc
<h1>htmlspecialchars($a)</h1>
heredoc; //ex2輸出為 <h1>htmlspecialchars(123)</h1>
如果$b=htmlspecialchars($row["subject"]);
ex3:
echo <<<heredoc
<h1>$b</h1>
heredoc; //ex3可以正常,函式的功能也有作用到
請問有別的寫法嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.202.165
推 johnney:基本變數轉換還可以 work...難一點的函數、陣列恐怕不行 01/20 17:25
推 zx1986 :可以使用 {} 把變數包起來看看 02/26 13:16