2016-07-01 13 views
-1

我有運行它使用PHP的配置文件來繪製主index.php頁面PHP和IM試圖現在就清理了一下Web服務器它像:PHP的多行文字

$config['p1'] = 'Line one text'; 
$config['p2'] = 'Line 2 text'; 
$config['p3'] = 'Line 3 text'; 

,並在指數我有一個這樣的東西很多:

echo $p1; 
echo $p2; 
echo $p3; 

我要清理這個了一下如何使用我的配置文件,使使用一個配置文本設置這個樣子輸出多行,但IDK的究竟是如何做到這一點

$config['p1] = 'this is text on line 1', 
       'this is text on line 2', 
       'this is final line of text'; 

所以html頁面上輸出的用戶看到會是什麼樣

this is text on line 1 
this is text on line 2 
this is final line of text 

但不工作我該怎麼辦什麼即時試圖做的?或者是不可能的,我用它的方式。

+0

請正確拼寫。很難理解你的問題。 – PaulH

+0

這裏很基本的東西。如果您想在HTML中換行,則需要使用HTML換行符... – Devon

+0

請定義清理。 – PaulH

回答

1
$config['p1] = 'this is text on line 1', 
      'this is text on line 2', 
      'this is final line of text'; 

錯誤的語法:PHP不明白。它應該是

$config['p1'] = 'this is text on line 1'."<br>\n". 
      'this is text on line 2'."<br>\n". 
      'this is final line of text'; 

.運算符連接字符串。 或者,你可以寫:

$config['p1'] = 'this is text on line 1<br> 
      this is text on line 2<br> 
      this is final line of text'; 

因爲在PHP中,字符串可以在多條線路。

要輸出字符串,請使用

echo $config['p1'] 
+0

這沒有爲我工作它只是把它放在我的索引頁上的一行,其中echo $ config [ 'p1']在。像這樣:這是第一行上的文字
這是第2行上的文字....等它實際上在用戶看到的頁面上打印
Twml