drydaenth257216154 2011-02-15 22:00
浏览 63
已采纳

呼叫时间传递引用已弃用?

I read in many forums to remove the ampersand (&) before any $ listed in a variable, and I did, but doing so removes the functionality of the code I'm using. What should I do?

Demo here.

Code here:

<?php 

$val = $_GET['name'];
$path = "./images/".$val."/";
$file_array = array ();
readThisDir ( $path, &$file_array );

echo '<div class="gallery" style="display:block;" id="'.$val.'">';
echo '<ul>';
foreach ( $file_array as $file )
{
  if (strstr($file, "png")||strstr($file, "jpg")||strstr($file, "bmp")||strstr($file, "gif"))
  {
   list($width, $height) = getimagesize($file);
   $info = exif_read_data($file);           
   echo '<li><a href="javascript:void(0);"><img src="'.$file.'" width="'.$width.'" height="'.$height.'" alt="'.$file.'"/></a><span>'.$info['Title'].'<div class="gallerynav"><a href="javascript:void(0);" class="prevproject">&laquo;</a><a href="javascript:void(0);" class="nextproject">&raquo;</a></div></span></li>';
  }
}

echo '</ul>';
echo '</div>';

  function readThisDir ( $path, $arr )
  {
    if ($handle = opendir($path)) 
    {
        while (false !== ($file = readdir($handle))) 
        {
            if ($file != "." && $file != "..") 
            {
              if (is_dir ( $path."/".$file ))
              {
                readThisDir ($path."/".$file, &$arr);
              } else {
                $arr[] = $path."/".$file;
              }  
            }
        }
        closedir($handle);
    }
  }
?>
  • 写回答

4条回答 默认 最新

  • drqrdkfue521903877 2011-02-15 22:02
    关注

    You are supposed to mark the pass-by-reference in the function declaration, not where the function is called.

    ...
    function readThisDir ( $path, &$arr )
    { ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行