Blogger Information
Blog 17
fans 0
comment 0
visits 10615
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
8-21 之php基础
人生百态
Original
668 people have browsed it

1.png

实例

<!doctype html>
<html lang="zh-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h3>php字符串变量解析-单引号</h3>
    <?php
        $danName='单引号';
        echo '  "\\这是\''.$danName.'\'的变量解析"  ';
    ?>
    <h3>php字符串变量解析-双引号</h3>
    <?php
        $danName="双引号";
        echo "\"\\这是'{$danName}'的变量解析\""
    ?>
    <h3>herdoc语法</h3>
    <?php
    $danName="herdoc";
    echo <<<HEREDOC
         {$danName} \t \r \n 
          等价于使用了双引号的字符串,可以解析内部的变量和转义特殊字符
          <b>$danName</b>
HEREDOC;
?>
    <h3>nowdoc语法</h3>
    <?php
    $danName="herdoc";
    echo <<<'NOWDOC'
         {$danName} .$danName. '$danName' \t \r \n    <br>
         <b>nowdoc语法</b>相当于用单引号包装的字符串,可以用来包装html代码<br>
         <b>不能解析内部的变量和转义特殊字符</b>
NOWDOC;
    ?>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


1.png




Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post