php代码问题 php 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 file_exists 就只能检查本地文件,远程用get_headers获取头信息来判断,你这个需求在<img标签加个onerror也能解决。 var_dump(file_exists('http://saberlily-images.stor.sinaapp.com/load.jpg'));打印出来为false;话说file_exists貌似只能用来判断webroot下面的。 $id = isset($_POST['id'])? $_POST['id'] : 0;$filename = 'http://saberlily-images.stor.sinaapp.com/load.jpg';if(getimagesize($filename)){ echo '11<img src="'.$filename.'" width="auto" height="auto">';}else{ echo '<img src="http://saberlily-images.stor.sinaapp.com/load.jpg" width="auto" height="auto">';}'<img src=".$filename." width="auto" height="auto">';外面是单引号,$filename是不能解析的 file_exists只适用于本机或者网络共享文件夹的文件。 file_exists只能判斷本地的,判斷http的不行。<?php$filename = '/path/to/foo.txt';if (file_exists($filename)) { echo "The file $filename exists";} else { echo "The file $filename does not exist";}?>http://cn2.php.net/file_exists要判斷遠程文件是否存在可以這樣寫function check_remote_file($url){ $result = get_headers($url, 1); if($result[0]=='HTTP/1.1 200 OK'){ return true; }else{ return false; }}$id = isset($_POST['id'])? $_POST['id'] : 0;$filename = 'http://saberlily-images.stor.sinaapp.com/' .strval($id). '.jpg';if(check_remote_file($filename)){ echo '<img src=".$filename." width="auto" height="auto">';}else{ echo '<img src="http://saberlily-images.stor.sinaapp.com/load.jpg" width="auto" height="auto">';} 现在我在Dream Weaver能完美运行了,可是上传到SAE服务器上就不显示了。是什么情况 请教基于web做物流计价系统,开发思路 帮我一个html问题。 高手来推荐一本php的好书 PHP新手--PHP文件操作问题 求教php空白页的问题!谢谢各位大大了 PHP + MYSQL 的数据导入问题 计划托管一台服务器,请大家帮忙 php文件和数据库不在一个服务器上,速度是快了,还是慢了 散分了,开始学php了 session在windows下有效,在linux下无效 求解一个php数组的用法 php代码问题
打印出来为false;
话说file_exists貌似只能用来判断webroot下面的。
$filename = 'http://saberlily-images.stor.sinaapp.com/load.jpg';
if(getimagesize($filename)){
echo '11<img src="'.$filename.'" width="auto" height="auto">';
}else{
echo '<img src="http://saberlily-images.stor.sinaapp.com/load.jpg" width="auto" height="auto">';
}
'<img src=".$filename." width="auto" height="auto">';
外面是单引号,$filename是不能解析的
<?php
$filename = '/path/to/foo.txt';if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
http://cn2.php.net/file_exists要判斷遠程文件是否存在可以這樣寫function check_remote_file($url){
$result = get_headers($url, 1);
if($result[0]=='HTTP/1.1 200 OK'){
return true;
}else{
return false;
}
}$id = isset($_POST['id'])? $_POST['id'] : 0;
$filename = 'http://saberlily-images.stor.sinaapp.com/' .strval($id). '.jpg';
if(check_remote_file($filename)){
echo '<img src=".$filename." width="auto" height="auto">';
}else{
echo '<img src="http://saberlily-images.stor.sinaapp.com/load.jpg" width="auto" height="auto">';
}