The syntax of a nasty string

Source: Internet
Author: User
If there is a string, I want to assign it to a variable how it should be written, the string is very long ha
Such as
Variable is $TXJS

string is
onmouseout= "YCXL (' xla ');" onmouseover= "XSXL (' Xla ', GetPos (this, ' Top ') +16,getpos (this, ' left '));"

I write this error, I do not know why
$TXJS = ' onmouseout= ' ycxl (' xla '); "onmouseover=" XSXL (' Xla ', GetPos (this, ' Top ') +16,getpos (this, ' left '); "'

Here's the report error.
Parse error:syntax error, unexpected ' xla ' (t_string) in D:\WWW\dgcms\e\data\tmp\dt_templist6.php on line 159


Reply to discussion (solution)

All languages are the same, in order to avoid ambiguity
Double quotation marks in a string enclosed in double quotation marks and single quotation marks in a string enclosed in single quotation marks
All need to be escaped.
The escape character of the PHP convention is \

PHP also provides custom delimiters, which eliminates the hassle of escaping

$TXJS =<<< jsonmouseout= "YCXL (' xla ');" onmouseover= "XSXL (' Xla ', GetPos (this, ' Top ') +16,getpos (this, ' left ') );" JS;

I wrote a variable in the string, but escaped without the value of the output variable, but directly output the name of the variable, that is, output it
$cssbh

$TXJS = ' onmouseout= ' ycxl (\ ' {$cssbh}\ '); "onmouseover=" XSXL (\ ' {$cssbh}\ ', GetPos (this,\ ' top\ ') +16,getpos (this,\ ') Left\ ');

And
$TXJS = ' onmouseout= ' ycxl (\ ' \{$cssbh \}\ '), "onmouseover=" XSXL (\ ' \{$cssbh \}\ ', GetPos (this,\ ' top\ ') +16,getpos (this, \ ' left\ ')); "'; Not even a write.
Where's the mistake?

A PHP variable in a string that is replaced with a value only if it is enclosed in double quotation marks
This is the PHP convention, please follow. No, why?

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