 |
|
|  |
|
 |
14³â Àü |
¹®ÀÚ¿À» ±¸ºÐÇÏ´Â ´Ù¸¥ ¹æ¹ýÀº HERE docs ¹®¹ý("<<<")À» »ç¿ëÇÏ´Â °ÍÀÔ´Ï´Ù.
<<< ÀÌÈÄ¿¡ ½Äº°ÀÚ°¡ ¿Í¾ß ÇÏ°í ±× ´ÙÀ½¿¡ ¹®ÀÚ¿, ±× ´ÙÀ½¿¡ ÀοëÀ» ´Ý´Â ¾î¶² ½Äº°ÀÚ°¡ ¿Í¾ß ÇÕ´Ï´Ù.
´Ý±â ½Äº°ÀÚ´Â ±× ÁÙÀÇ Ã¹¹ø° Ä®·³¿¡¼ ½ÃÀ۵Ǿî¾ß ÇÕ´Ï´Ù.
¶ÇÇÑ ½Äº°ÀÚ´Â PHPÀÇ ´Ù¸¥ ¶óº§°ú °°Àº ¸í¸í±ÔÄ¢À» µû¶ó¾ß ÇÕ´Ï´Ù.
¿ÀÁ÷ ¾ËÆĺª ¼ýÀÚ¿Í ¹ØÁÙÀ» Æ÷ÇÔÇÏ°í ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ³ª ¹ØÁÙ·Î ½ÃÀ۵Ǿî¾ß ÇÕ´Ï´Ù.
´Ý±â ½Äº°ÀÚ¸¦ °®´Â ÁÙÀº °¡´ÉÇÑ ¼¼¹ÌÄÝ·Ð(;)À» Á¦¿ÜÇÏ°í ´Ù¸¥ ¹®ÀÚ¸¦ Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù´Â °Í¿¡ ÁÖÀÇÇؾßÇÕ´Ï´Ù.
HERE docs ¹®¹ý¿¡¼ ÅؽºÆ®´Â Å«µû¿ÈÇ¥°¡ ¾øÁö¸¸ Å«µû¿ÈÇ¥·Î µÑ·¯½ÎÀÎ ¹®Àڿó·³ µ¿ÀÛÇÕ´Ï´Ù.
( HERE docs ¹®¹ý »ç¿ë ¿¹ )
$str = << Example of string
spanning multiple lines
using heredoc syntax.
EOD;
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1','Bar2','Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo << 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;
?>
¡Ø ÁÖÀÇÁ¡
HERE docs ¾È¿¡ php º¯¼ö¸¦ Çѱ۰ú ºÙ¿©¼ Ãâ·ÂÇÒ¶§ ¿¡·¯°¡ ¹ß»ýÇÒ ¼ö ÀÖ½À´Ï´Ù.
¿¡·¯ --> $year³â $month¿ù
À̶§´Â Áß°ýÈ£·Î ¹¾îÁÖ¸é ¿Ã¹Ù·Î Ãâ·ÂµË´Ï´Ù.
<?
$year = date('Y');
$month = date('m');
$str = <<<EOD
<span style="font:14pt µ¸À½Ã¼;color:#FF9900;"><b> {$year}³â {$month}¿ù </b></span>
EOD;
echo $str;
?>
|
|
̵̧ : 280 |
̵̧
¸ñ·Ï
|
|
|  |
|