谢谢大家的帮助 第三个问题: <?php $file="1.txt"; $fp=fopen($file,"r") or die("the file is not exists"); $file_size=filesize($file); echo "the 18_2.php size is :".$file_size."<br>"; //输出10 $chars=0; while(!(feof($fp))) { $fc=fgetc($fp); $chars=$chars+1; } echo "<br>the file total char is : $chars"; //输出11 //与filesize($file)的输出怎么不一样? fclose($fp); ?>还有我想问:一个换行符是2个字符吗? 我的1.txt文件是三行只有6个字符呀
filesize 是文件大小 $chars 是字符个数,两个没有可比性
哈哈,真是汗啊 但我还是不明白以下三行: ab abc a ———————————— while(!(feof($fp))) { $fc=fgetc($fp); $chars=$chars+1; } echo "<br>the file total char is : $chars"; //怎么会输出11 第四个弱智问题:<?php $fp=fopen("18_3.php","r") or die("the file is not exists"); $file_size=filesize("18_3.php"); echo "the file size is: $file_size<br>"; $fs=fseek($fp, 22, SEEK_CUR) or die("you wrong"); //这怎么都定位不了?那里错了? $fstring=fgets($fp,5); echo "you get char is :$fstring"; fclose($fp); ?> 输出是: the file size is: 435 you wrong
说明:虽然php为了简化书写,在适当的配置下允许使用未经定义的变量。但这毕竟不是很严密的。
所以在引用http变量时,最好先判断以下:
if(isset($fiction))
{
echo "<br>fiction</br>";
}
if(isset($horror))
{
echo "<br>horror</br>";
}
解决办法:
php.ini中error_reporting = E_ALL & ~E_NOTICE
或在程序开头加上:
error_reporting(E_ALL & ~E_NOTICE);
只要的不同点在于,get是显式的传递,且有2048字节的限制;post是隐式的传递,理论上无限制。
对于只要的不同点在于,get是显式的传递,且有2048字节的限制;post是隐式的传递,理论上无限制。
还是不大理解
我写的两个程序文件a.html与b.php都不止2048字节,那她们怎么都可以传递?默认是get吧?
我没改动呀
fiction=1&horror=1"
默认我忘了
第三个问题:
<?php
$file="1.txt";
$fp=fopen($file,"r") or die("the file is not exists");
$file_size=filesize($file);
echo "the 18_2.php size is :".$file_size."<br>"; //输出10
$chars=0;
while(!(feof($fp)))
{
$fc=fgetc($fp);
$chars=$chars+1;
}
echo "<br>the file total char is : $chars"; //输出11
//与filesize($file)的输出怎么不一样?
fclose($fp);
?>还有我想问:一个换行符是2个字符吗?
我的1.txt文件是三行只有6个字符呀
$chars 是字符个数,两个没有可比性
但我还是不明白以下三行:
ab
abc
a
————————————
while(!(feof($fp)))
{
$fc=fgetc($fp);
$chars=$chars+1;
}
echo "<br>the file total char is : $chars"; //怎么会输出11 第四个弱智问题:<?php
$fp=fopen("18_3.php","r") or die("the file is not exists");
$file_size=filesize("18_3.php");
echo "the file size is: $file_size<br>";
$fs=fseek($fp, 22, SEEK_CUR) or die("you wrong"); //这怎么都定位不了?那里错了?
$fstring=fgets($fp,5);
echo "you get char is :$fstring";
fclose($fp);
?>
输出是:
the file size is: 435
you wrong
{
$fc=fgetc($fp);
$chars=$chars+1;
echo "第$chars个字符是$fc <br>";
}$fs=fseek($fp, 22);
if($fs == -1)echo "you wrong";
$fs=fseek($fp, 4, SEEK_CUR); //如果改成
//$fs=fseek($fp, 4, SEEK_CUR) or die("wrong")就输出wrong
if($fs==-1)
{ echo "<br>you are wrong";} //这里就没输出
$fstring=fgets($fp,5);
if(!$fstring){echo "<br>fgets() wrong";} //输出:fgets() wrong
echo "<br>you get char is :$fstring"; //输出:you get char is :哪里出错了?最后才能得到正确的$fstring??
哪个大哥能讲讲pack()与unpack()函数
书上只是点一下而已,不大懂
最好举个小例子说说,谢谢