新人求教,php中fopen()打开window本地文件反斜线\的问题
<?php$myfile=fopen("C:\wamp\www\demo\d1\d2\d3.txt","r")ordie("Unabletoopenfile!");ech...
<?php
$myfile = fopen("C:\wamp\www\demo\d1\d2\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
<?php
$myfile = fopen("C:\\wamp\\www\\demo\\d1\\d2\\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
<?php
$myfile = fopen("d1\d2\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
<?php
$myfile = fopen("d1\\d2\\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
亲测以上四种都可以,有些地方说window下是两个反斜线\\,我试下一个反斜线\也行的。
到底是怎么回事,各位平常是怎么写的? 展开
$myfile = fopen("C:\wamp\www\demo\d1\d2\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
<?php
$myfile = fopen("C:\\wamp\\www\\demo\\d1\\d2\\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
<?php
$myfile = fopen("d1\d2\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
<?php
$myfile = fopen("d1\\d2\\d3.txt", "r") or die("Unable to open file!");
echo fread($myfile,30);
fclose($myfile);
?>
亲测以上四种都可以,有些地方说window下是两个反斜线\\,我试下一个反斜线\也行的。
到底是怎么回事,各位平常是怎么写的? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询