1

first of all Im completely new to PHP, never done it before.. zero skills with it.. but I got a task to solve some errors in my job but I dont know what to do with it..

I have error here

code:

<?$this->box->begin('rdgrey rdopen',null,'tree')?>
<?$this->box->headbegin();?>
    <span class="title"><?=lang('site_tree')?> </span>
<?$this->box->headend();?>
<?$this->box->contentbegin('');?>   

<?
  function pr(&$list,$key,&$c){
     echo '<ul class="tree">';
     $l=count(@$list[$key]);
     $i=0;
     if($l)
        foreach($list[$key] as $k=>$v){
            $has = count(@$c->content->config['has'][$v['type']]);
            echo '<li class="',($k==$l-1?'last ':''),(count(@$c->content->config['has'] 
         [$v['type']])?'folder ':'file ' ),
         (isset($list[$v['url']])?'open ':''),'type_',($v['type']),'"> 
         <span onClick="tree_tog(this)"></span><a href="',site_url('panel/'. 
         ($has?'index':'edit').'/'.$v['lang'].'/'.$v['nid'],null,false),'">
         ',character_limiter($v['name'],40),'</a>';
         if($v['type']!='root'&&isset($list[$v['url']]))
         pr($list,$v['url'],$c);
    
         echo '</li>';
         }
   //if($key)
   //echo '<li class="last"><a href="" onClick="return tognode(\'',$key,'\',this)">+</a></li>';

     echo '</ul>';
 }

  $lang = isset($_GET['lang']) ? $_GET['lang'] : @$node['lang'];
  pr($this->content->getTree(@$node['url'],$lang),'/',$this);

   ?>


   <?$this->box->contentend();?>   
   <?$this->box->end()?>

theres problem in this line

pr($this->content->getTree(@$node['url'],$lang),'/',$this);

It is saying that only variables should be passed by a reference.

Can somebody help me? How should I solve this?

  • 1
    You should really let your code breathe -- some extra spaces and proper formatting will make your code MUCH easier to read (and in turn, easier to troubleshoot!). – Qirel Jul 01 '20 at 20:14
  • `&$list` is passed by reference, but you are jambing a whole object method call in there. Assign a variable the result of `$var = $this->content->getTree(@$node['url'],$lang)`, then pass that `$var` variable instead. – IncredibleHat Jul 01 '20 at 20:15
  • However I really question how it is you have a stray `function pr() {}` in what I can only think is an object method itself (the use of $this->)... why is that pr function not a method of that object instead? – IncredibleHat Jul 01 '20 at 20:17
  • @Qirel well, it is not code of mine Im just correcting code issues, but thanks for advice. – Tomáš Várady Jul 02 '20 at 07:06
  • @IncredibleHat thx that just solved the problem but now I got 2 more errors lol – Tomáš Várady Jul 02 '20 at 07:18

1 Answers1

0

IncredibleHat indeed your answer was correct. Ive had to create variable and set this result $tmp = $this->content->getTree(@$node['url'],$lang) to it.

all credit goes to IncredibleHat