之前一直觉得PHP中使用单引号和双引号没有多大的区别,但是今天在做例子的时候发现,其实还是有区别的。

代码一:

$tempfilename=tempnam('d:/tmp/','data-');
echo 'temporary data will be stored in $tempfilename';

运行上面的代码输出的是引号里面原原本本的内容,不会把$tempfilename当做变量处理;

代码二:

$tempfilename=tempnam('d:/tmp/','data-');
echo "temporary data will be stored in $tempfilename";

此时我将单引号改为双引号后,输出的就是我想要的结果了。

temporary data will be stored in D:\tmp\dat524A.tmp

做个简单的备忘。


相关文章:

  • 2021-06-18
  • 2021-11-27
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2022-01-04
相关资源
相似解决方案