首页 > 其他 > 详细

string

时间:2016-07-08 11:49:01      阅读:239      评论:0      收藏:0      [点我收藏+]

字符串三种定义方式:

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
 
 
 
 

string

原文:http://www.cnblogs.com/docter/p/5652764.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!