Hey guys, how do I write " and ' characters when I'm doing it via PHP eg
<?php
开发者_如何学运维$newFile = "<?php echo 'quote: "hello world"'; ?>"
file_put_contents('index.php', $newFile);
?>
Thanks
\
is used to 'escape' things.
$newfile = "<?php echo 'quote: \"hello world\"'; ?>";
You can only use one sort of quotes in a string literal. If another quote is to appear within the literal it needs to be escaped by a \
$newFile = "<?php echo 'quote: \"hello world\"'; ?>";
file_put_contents('index.php', $newFile);
$newFile = "<?php echo 'quote: \"hello world\"'; ?>"
Read this Strings manual.
精彩评论