php 如何输出多行字符串
2个回答
展开全部
<?php
02 $str = <<<EOD
03 Example of string
04 spanning multiple lines
05 using heredoc syntax.
06 EOD;
07
08 /* 含有变量的更复杂示例 */
09 class foo
10 {
11 var $foo;
12 var $bar;
13
14 function foo()
15 {
16 $this->foo = 'Foo';
17 $this->bar = array('Bar1', 'Bar2', 'Bar3');
18 }
19 }
20
21 $foo = new foo();
22 $name = 'MyName';
23
24 echo <<<EOT
25 My name is "$name". I am printing some $foo->foo.
26 Now, I am printing some {$foo->bar[1]}.
27 This should print a capital 'A': x41
28 EOT;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询