string

字符串三种定义方式:

1.双引号定义: 当双引号中包含变量时,变量会与双引号中的内容连接在一起;<双引号当成变量>

 $str="string";

 echo “$str”;   //string;

2.单引号定义: 当单引号中包含变量时,变量会被当做字符串输出。

 echo '$str'  //$str

3.Heredoc定义长字符串,字符串内变量可被解析,结尾加分号,标识符加分号;

   <?php

  $str2 = <<<ET
  heredoc test!!!
  $str
 
  ET;
 
  echo $str;
  ?>
  // heredoc test!!! string
4.Nowdoc定义长字符串,字符串内变量不被解析,结尾加分号,标识符加分号;
  <?php
  $str2 = <<<'ET'
  heredoc test!!!
  $str
 
  ET;
 
  echo $str;
  ?>
// heredoc test!!! $str
 
 
 
 
posted @ 2016-07-08 11:19  Docter  阅读(103)  评论(0编辑  收藏  举报