Php 我能';不显示默认图像?
如果在特定文件夹中找到用户定义的图像,我希望显示该图像;如果未找到,则显示默认图像Php 我能';不显示默认图像?,php,html,Php,Html,如果在特定文件夹中找到用户定义的图像,我希望显示该图像;如果未找到,则显示默认图像 <img src="user_images/<?php echo file_exists('user_images/'.$user.'.jpg')? $user.'.jpg' : 'img/logo-small.png'?>" alt="profile pic" class="userImage" /> “alt=“profile pic”class=“userImage”/ 这似乎不
<img src="user_images/<?php echo file_exists('user_images/'.$user.'.jpg')? $user.'.jpg' : 'img/logo-small.png'?>" alt="profile pic" class="userImage" />
“alt=“profile pic”class=“userImage”/
这似乎不起作用。我哪里出错了?您需要回显/打印文件名 试一试
“alt=“profile pic”class=“userImage”/
您需要回显/打印文件名
试一试
“alt=“profile pic”class=“userImage”/
两个图像中哪一个没有显示?无?是$user
.jpg始终是a.jpg?@JeroenBellemans已修复,但仍不工作这两个图像中哪一个没有显示?无?是$user
。jpg始终是a.jpg?@JeroenBellemans已修复,但仍不工作生成的HTML代码是什么样子的?您可以直接访问图像吗你访问URL吗?我只会使用一个常规的if语句生成的HTML代码是什么样子的?你能通过访问URL直接访问图像吗?我只会使用一个常规的if语句
<img src="user_images/<?php echo file_exists('user_images/'.$user.'.jpg')? $user.'.jpg' : 'img/logo-small.png'?>" alt="profile pic" class="userImage" />