引号内的 PHP 引号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21107329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:49:46 来源:igfitidea点击:
PHP quotes inside quotes
提问by THEJENSMAN
Is it possible to put quotes inside quotes?
是否可以将引号放在引号内?
If so how?
如果是这样怎么办?
Here is my code:
这是我的代码:
<?php
echo '<span onclick="$(this).addClass('selected');"> </span>';
?>
回答by gturri
回答by THEJENSMAN
You could do this:
你可以这样做:
<?php
// some code
?>
<span onclick="$(this).addClass('selected');"> </span>
<?php
// some more code.
?>
回答by Ronny Sherer
Heredoc is the perfect solution for this:
Heredoc 是一个完美的解决方案:
<?php
echo <<< HereDocString
<span onclick="$(this).addClass('selected');"> </span>
HereDocString;
?>

