PHP中定界符的使用注意事项

来源:互联网 发布:hp扫描仪软件 编辑:程序博客网 时间:2024/06/04 19:54
<?php
//1.在开始的定界符中,一定要让定界字符串左边挨着<<<,写结束定界符号时一定要直接回车顶格写(连空格都不可以有);
//2.结束的定界符号要和开始的字符串一致;
//3.使用定界字符时,支持解析双引号和转义字符的功能;
$int=10;
$str1=<<<dingjie
       this $int is a demo;
this is a\n test;
this is the\r dingjie.txt;
this is the open ;
dingjie;
echo $str1;
//4.使用定界符号可以有效的阻止因为单双引号嵌套而产生的报错;
//5.要想让定界符号失去双引号的功能,可以使用将开始定界符号加上单引号的方法;
$str2=<<<'hello'
        this 'is' $int the two simple;
i 'love\n php';
i "fall in\r love with" study;
A person who know the meaning of studying,he knows the meaning of the life;
hello;
echo $str2;
?>
原创粉丝点击