开发者

PHP file_put_contents or fwrite ' and " characters

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜