[英]can't write a file properly using php
<?php
$CreateFile = fopen("allinfo.html","a") or die("unable to create file");
$up = "<div class="infofilediv">";
$fwrite($CreateFile,$up);
$fclose($CreateFile);
?>
When I am creating this html file I am not able to write "infofilediv" with double quotation marks. 创建此html文件时,我无法用双引号写“ infofilediv”。 How am I able to escape these characters?
我如何逃脱这些角色?
Escape the double-quotes around infofilediv
and $ before function: 转义
infofilediv
和$前的双引号:
$CreateFile = fopen("allinfo.html","a") or die("unable to create file");
$up = "<div class=\"infofilediv\">";
fwrite($CreateFile,$up);
fclose($CreateFile);
you have two problem first with double-quotes here : 您首先在两个引号中遇到两个问题:
$up = "<div class="infofilediv">";
you can solve it by two ways : 您可以通过两种方式解决它:
1) use double-quotes first time and single-quotes second vise versa like this : 1)第一次使用双引号,第二次使用单引号,如下所示:
$up = "<div class='infofilediv'>";
2) escape double-quotes in second time like this : 2)像这样第二次转义双引号:
$up = "<div class=\"infofilediv\">";
second with $ before function 第二个带$的函数
$fwrite($CreateFile,$up);
$fclose($CreateFile);
replace with 用。。。来代替
fwrite($CreateFile,$up);
fclose($CreateFile);
$ use with variables $与变量一起使用
$hello="hello world";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.