我有一个运行php的网络服务器,它使用php配置文件来绘制主要的index.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 :(得分: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']