Heredoc string
본문
Example #2 Heredoc string quoting example
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
?>
위 예제의 출력:
My name is "MyName". I am printing some Foo. Now, I am printing some Bar2. This should print a capital 'A': A
Example #6 Nowdoc string quoting example
<?php
$str = <<<'EOD'
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
public $foo;
public $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<'EOT'
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
EOT;
?>
위 예제의 출력:
My name is "$name". I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should not print a capital 'A': \x41
[이 게시물은 듀라님에 의해 2015-04-03 10:29:17 워드프레스에서 이동 됨]
[이 게시물은 최고관리자님에 의해 2017-06-10 14:26:42 PHP에서 이동 됨]
0
0
페이지 정보
듀라 (121.♡.101.20) 작성일15-04-02 21:52 조회2,001회 댓글0건관련링크
댓글목록
등록된 댓글이 없습니다.