Blogger Information
Blog 2
fans 0
comment 0
visits 1247
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP对字符串的处理规则——2018/4/11 作业
周生的第一个博客
Original
493 people have browsed it

线上第1次课程课后作业:

   代码:

实例

<?php
 /**
  *定界符:单引号,双引号
  */
 $siteName='php中文网';
 $answer1='我在用{$siteName}学习PHP.';
 echo $answer1; //单引号不解析变量,直接原样输出
 echo '<hr>';
 $answer2="我在用{$siteName}学习PHP.";
 echo $answer2;//双引号解析变量,输出变量的值
 echo '<hr>';
 //转义字符(特殊字符)
 $answer3='我在用{\$siteName}学习PHP.';
 echo  $answer3;//不解析特殊字符,原样输出
 echo '<hr>';
 $answer4="我在用{\$siteName}学习PHP.";
 echo  $answer4;//解析特殊字符
 echo '<hr>';
 /**
  *heredoc语法,nowdoc语法定义字符串
  */
  //heredoc
  $heredoc=<<<AAAA
  我用{$siteName}学习,\n这是个不错的选择.
AAAA;
  echo $heredoc;//解析变量及特殊字符 
  echo '<hr>';
  //nowdoc
  $nowdoc=<<<'BBBBBB'
  我用{$siteName}学习,\n这是个不错的选择.
BBBBBB;
  echo $nowdoc;//不解析变量及特殊字符
  echo '<hr>';
  ?>

运行实例 »

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








实例

<?php
  /**
   *定界符:单引号,双引号
  */
 $siteName='php中文网';
 $answer1='我在用{$siteName}学习PHP.';
 echo $answer1; //单引号不解析变量,直接原样输出
 $answer2="我在用{$siteName}学习PHP.";
 echo $answer2;//双引号解析变量,输出变量的值

运行实例 »

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






Correction status:Uncorrected

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