简体   繁体   English

在PHP中,echo后跟两个单引号是什么意思?

[英]In PHP, what does echo followed by two single quotes mean?

I am going through someone else's code for a very old site and it has a lot of lines like this: 我正在为一个非常老的站点浏览其他人的代码,它有很多这样的代码行:

echo '';

I am not familiar with PHP, but having quickly gone through a syntax tutorial, it seems that this command would be printing the contents of the single quotes. 我对PHP并不熟悉,但是很快地学习了语法教程,似乎该命令将打印单引号的内容。 However, the single quotes are empty, and there are LOTS of instances like these. 但是,单引号是空的,并且有很多这样的实例。

What is the purpose of having these lines, and how did they end up in the code? 拥有这些行的目的是什么,它们如何最终出现在代码中?

You are right, they just print out empty string. 没错,它们只是打印出空字符串。 I can only guess as to how they got into your code but it is surely safe to delete them. 我只能猜测它们是如何进入您的代码的,但是删除它们肯定是安全的。

Single or double quotes are used to denote strings, so with: 单引号或双引号用于表示字符串,因此:

echo '';

You are printing empty string essentially nothing. 您正在打印字符串,基本上什么也没有。

the only idea i can think of choosing '' vs "" is: 我能想到的选择“ vs”的唯一想法是:

echo '"';    // print "
echo "'";    // print ' 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM