简体   繁体   中英

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. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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