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服务器上就不显示了。是什么情况 php生成迷宫寻址函数 php中文输出英文的问题,在线等 如何根据用户是否登陆,改变菜单栏的内容? 谁能告诉我网上购物系统是怎么与银行系统连接的 smarty的问题,如何选择多个checkbox值? php 关于foreach双循环中断、跳出的问题 新手问题:何为句柄 在Mediaplayer在网页中播放新闻,我不想让人看到 Mediaplayer 右键 -》属性 中的连接,该怎么办? 哪位能提供时差转换的代码??? 怎么会有错呢,简单的json读取 求解一个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">';
}