php函数不会显示图像
我无法使用php函数获取要显示的图像。所有权限都已授予,图像位置正确,但获取此权限。请参见图片 index.php文件php函数不会显示图像,php,html,image,Php,Html,Image,我无法使用php函数获取要显示的图像。所有权限都已授予,图像位置正确,但获取此权限。请参见图片 index.php文件 function.inc.php文件 函数fetchProfile($conn){ 如果($rowImg['status']==0){ $username=$row['uid']; $image='../assets/img/profile.png'; 回声“ “$username。”; 图像的来源是。/assets/img/profile.png,如果index.php
function.inc.php文件
函数fetchProfile($conn){
如果($rowImg['status']==0){
$username=$row['uid'];
$image='../assets/img/profile.png';
回声“
“$username。”;
图像的来源是。/assets/img/profile.png
,如果index.php文件位于站点的根目录下,图像不出现是正常的,因为您试图获取站点外部的文件
问题可能是文件夹资产在您的站点之外,或者您的路径不正确。已解决->
从不同文件中的函数进行操作时,路径将保持在index.php
的位置,而不是function.inc.php的
位置
index.php文件
function.inc.php文件
函数fetchProfile($conn){
如果($rowImg['status']==0){
$username=$row['uid'];
$image='assets/img/profile.png';
回声“
“$username。”;
检查您设置的图像的位置。这是正常的,您有两个不同的路径?jsoneassets/js/…'和image
。/assets/img…`。请随身携带,您的脚本标记应该在body元素上,而不是在外部:)它们是两个不同的文件index.php
&function.inc.php
,位置/路径a你说得对。
<?php
include 'inc/function.inc.php';
include 'header.php';
fetchProfile($conn);
?>
<script src="assets/js/bootstrap.js"></script>
</body>
</html>
function fetchProfile($conn){
if ($rowImg['status'] == 0) {
$username = $row['uid'];
$image = '../assets/img/profile.png';
echo "<img src='".$image."' style='width:120px;height:120px' class='img-responsive' alt=''>
<div class='captionN'>
<h4>" . $username . "</h4></div>;
<?php
include 'inc/function.inc.php';
include 'header.php';
fetchProfile($conn);
?>
<script src="assets/js/bootstrap.js"></script>
</body>
</html>
function fetchProfile($conn){
if ($rowImg['status'] == 0) {
$username = $row['uid'];
$image = 'assets/img/profile.png';
echo "<img src='".$image."' style='width:120px;height:120px' class='img-responsive' alt=''>
<div class='captionN'>
<h4>" . $username . "</h4></div>;