url.txt文件中含有:
http://mail.jxxm.com
http://mail.xinglongmuye.com/mail/postoffice/login.php
http://www.yny18.com
上面的三行链接,一行一个
现要php代码输出来,怎么实现呀,多谢
http://mail.jxxm.com
http://mail.xinglongmuye.com/mail/postoffice/login.php
http://www.yny18.com
上面的三行链接,一行一个
现要php代码输出来,怎么实现呀,多谢
<?php
$handle = fopen('url.txt','r');
if($handle){
while (!feof($handle)){
$content = fgets($handle);
echo $content.'<br>';
}
}
?>
再帮我想一下,
现要再写一行内容到url.txt中,如果url.txt文件中有此内容,就不写,如果没有,就写入,怎么实现呀
多谢
<?php
$url = "http://www.baidu.com";
$handle = fopen('url.txt','a+');
if($handle){
while (!feof($handle)){
$content = fgets($handle);
if($content == $url){
echo '已存在该内容';
return false;
}
}
if(fwrite($handle,"\r\n".$url ) === false){
echo '写入失败';
return false;
}else{
echo '写入成功';
return true;
}
}
?>