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?