码迷,mamicode.com
首页 > 其他好文 > 详细

string

时间:2016-07-08 11:50:19      阅读:100      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!