单引号: 字符串中需要转义的特殊字符只有反斜杠和单引号本身(其它的一边去).
例子:
print 'I/'ve gone to the '
//输出: I've gone to the
print 'Would you pay $1.75 for 8 ounces of tap water?';
//输出: Would you pay $1.75 for 8 ounces of tap water?
print'In double-quoted strings , newline is represented by /n';
//输出: In double-quoted strings , newline is represented by /n
print '你是个/"猪'; // 你是个/"猪
因为PHP不会检查单引号字符串中插入变量及任何转义序列,所以用这种方式定义字符串不仅直观而且速度快
****************************************************************************
双引号字符串虽然不能识别转义的单引号(因为这没有必要, 双引号中可以直接输出 单引号),但是却能够识别插入的变
量和表1-1中的转义序列.
转义序列 字符
/n 换行符(ASCII码10)
/r 回车符(ASCII码13)
/t 制表符(ASCII码9)
// 反斜杠
/$ 钱符号
/" 双引号
/0至/777 八进制数值
/x0至/xFF 十六进制数值
双引号例子:
print "I've gone to the store.";
//输出 I've gone to the store.
print "The sauce cost /$10.25."
//输出:The sauce cost $10.25.
$cost = '$10.25';
print "The sauce cost $cost";
//输出:The sauce cost $10.25.
print "The sauce cost /$/061/060./x32/x35";
输出:The sauce cost $10.25.