Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php函数不会显示图像_Php_Html_Image - Fatal编程技术网

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

我无法使用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文件位于站点的根目录下,图像不出现是正常的,因为您试图获取站点外部的文件

问题可能是文件夹资产在您的站点之外,或者您的路径不正确。

已解决-> 从不同文件中的函数进行操作时,路径将保持在
index.php
的位置,而不是
function.inc.php的
位置

index.php文件


function.inc.php文件

函数fetchProfile($conn){
如果($rowImg['status']==0){
$username=$row['uid'];
$image='assets/img/profile.png';
回声“
“$username。”;

检查您设置的图像的位置。这是正常的,您有两个不同的路径?jsone
assets/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>;