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'php' 카테고리의 다른 글
| PHP IE 브라우저 체크 [터치추가] (0) | 2016.02.11 | 
|---|---|
| PHP get_defined_vars 모든 변수 출력 (0) | 2014.07.24 | 
| 주민번호 법인 사업자 체크 관련 (0) | 2014.06.21 | 
| [PHP] include된 파일목록 출력하기 (1) | 2013.10.17 | 
| PHPExcel 파일 출력 (0) | 2013.04.30 |