For example, how to insert a variable into a string? $ s & nbsp ;=& nbsp ;$ _ GET [& quot; word & quot;]; echo & nbsp; & quot; how does your & nbsp; word & nbsp; is & nbsp insert variables into strings?
For example,
$ S = $ _ GET ["word"];
Echo "your word is $ s ";
There is no problem with running the above code, but it won't work if it is changed to this:
Echo 'Your word is $ s ';
Don't use '', but the actual situation is that sometimes'' is required. for example, if I want to output link, because "" is used in html, so in order to avoid inserting too many \ S, php will use print ''to output. how can we solve the problem of inserting variable strings?
I can use printf to solve the problem, but it is always very troublesome. Is there a simpler way, just like inserting string variables in?
------ Solution --------------------
Echo 'Your word is {$ s} '; --> echo "your word is {$ s }";
What is in single quotes is output.
------ Solution --------------------
If you want to use single quotes
Then replace the eval or character
------ Solution --------------------
Check this function ~~~
Eval
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.