php str_replace single quotation marks double quotation marks difference

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags difference example function network network programming note php php tutorial

php str_replace () function of the specific situation

str_replace ($ search, $ replace, $ subject)

E.g

1

str_replace ("n", "
", '465s4d6f5s4ad1as65d4fa6sn54df65sdafgsdfn65g4sd65g4hdf6n54ghd6fbghdfgh'); // Note the quotes

Output: 465s4d6f5s4ad1as65d4fa6sn54df65sdafgsdfn65g4sd65g4hdf6n54ghd6fbghdfgh

2

str_replace ("n", "
"," 465s4d6f5s4ad1as65d4fa6sn54df65sdafgsdfn65g4sd65g4hdf6n54ghd6fbghdfgh "); // Note the quotes

Output:

465s4d6f5s4ad1as65d4fa6s

54df65sdafgsdf

65g4sd65g4hdf6

54ghd6fbghdfgh

3

str_replace ('n', '
', "465s4d6f5s4ad1as65d4fa6sn54df65sdafgsdfn65g4sd65g4hdf6n54ghd6fbghdfgh"); // Note the quotes

Output:

465s4d6f5s4ad1as65d4fa6s 54df65sdafgsdf 65g4sd65g4hdf6 54ghd6fbghdfgh

Note: Single quotes simply represent pure strings

The double quotes are to be compiled by the compiler

In other words, 'n' and 'n' are different, the former refers to the string n, which is the compiler n, is the meaning of the transfer character

So when only the $ search and $ subject variables are single or double quotes at the same time will have an effect.

From the text box or take out the value is transferred, that is to say there is a transfer of n, so use 'n' is useless, be sure to use "n"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.