Hello all,
The following code line :
array_push($thi s->content, &$elt);
produces the following error :
Warning: Call-time pass-by-reference has been deprecated - argument
passed by value; If you would like to pass it by reference, modify the
declaration of array_push(). If you would like to enable call-time
pass-by-reference, you can set allow_call_time _pass_reference to true in
your INI file. However, future versions may not support this any longer.
in /home/sites/site77/web/lib/xml/General_tag.cla ss.php on line 56
What is the propest way to fix it ?
Thx, Thierry.
PS 1 : I can not modify the "online" php.ini file. I'm using PHP v4.1.2
online, and v4.2.0 on local for my tests.
PS 2 : Here is the complete source code.
<?php
/**
* General_tag
*/
class General_tag
{
var $id = "";
var $tag_name = "noname";
var $attributes = array();
var $content = array();
function get_id()
{
return $this->id;
}
function set_id($id)
{
$this->id = $id;
}
function get_tag_name()
{
return $this->tag_name;
}
function set_tag_name($t ag_name)
{
$this->tag_name = $tag_name;
}
function &get_attribute_ keys()
{
return array_keys($thi s->attributes);
}
function get_attribute($ key)
{
return $this->attributes[$key];
}
function put_attribute($ key, $value)
{
$this->attributes[$key] = $value;
}
function is_empty()
{
return count($this->content) == 0;
}
function add(&$elt)
{
array_push($thi s->content, &$elt);
}
function &get_content ()
{
return $this->content;
}
function export(&$result )
{
$this->export_start($ result);
$this->export_content ($result);
$this->export_end($re sult);
}
function export_start(&$ result)
{
$result .= "<" . $this->get_tag_name() ;
while (list ($key, $value) = each ($this->attributes))
{
$result .= " " . $key . "=\"" . $value . "\"";
}
$result .= ">";
}
function export_end(&$re sult)
{
$result .= "</" . $this->get_tag_name () . ">";
}
function export_content( &$result)
{
foreach($this->content as $elt)
{
$elt->export($result );
}
}
function &find_by_id($id )
{
if($this->get_id() == $id)
{
return $this;
}
else
{
$content = &$this->get_content( );
foreach(array_k eys($content) as $key)
{
$elt = &$content[$key];
$result = &$elt->find_by_id($id );
if($result != null)
{
return $result;
}
}
return null;
}
}
function remove_content_ by_id($id)
{
$save_content = $this->get_content( );
$this->content = array();
foreach(array_k eys($save_conte nt) as $key)
{
$elt = &$save_conte nt[$key];
if($id != "all" && $elt->get_id() != $id )
{
$this->add($elt);
}
}
}
}
?>
The following code line :
array_push($thi s->content, &$elt);
produces the following error :
Warning: Call-time pass-by-reference has been deprecated - argument
passed by value; If you would like to pass it by reference, modify the
declaration of array_push(). If you would like to enable call-time
pass-by-reference, you can set allow_call_time _pass_reference to true in
your INI file. However, future versions may not support this any longer.
in /home/sites/site77/web/lib/xml/General_tag.cla ss.php on line 56
What is the propest way to fix it ?
Thx, Thierry.
PS 1 : I can not modify the "online" php.ini file. I'm using PHP v4.1.2
online, and v4.2.0 on local for my tests.
PS 2 : Here is the complete source code.
<?php
/**
* General_tag
*/
class General_tag
{
var $id = "";
var $tag_name = "noname";
var $attributes = array();
var $content = array();
function get_id()
{
return $this->id;
}
function set_id($id)
{
$this->id = $id;
}
function get_tag_name()
{
return $this->tag_name;
}
function set_tag_name($t ag_name)
{
$this->tag_name = $tag_name;
}
function &get_attribute_ keys()
{
return array_keys($thi s->attributes);
}
function get_attribute($ key)
{
return $this->attributes[$key];
}
function put_attribute($ key, $value)
{
$this->attributes[$key] = $value;
}
function is_empty()
{
return count($this->content) == 0;
}
function add(&$elt)
{
array_push($thi s->content, &$elt);
}
function &get_content ()
{
return $this->content;
}
function export(&$result )
{
$this->export_start($ result);
$this->export_content ($result);
$this->export_end($re sult);
}
function export_start(&$ result)
{
$result .= "<" . $this->get_tag_name() ;
while (list ($key, $value) = each ($this->attributes))
{
$result .= " " . $key . "=\"" . $value . "\"";
}
$result .= ">";
}
function export_end(&$re sult)
{
$result .= "</" . $this->get_tag_name () . ">";
}
function export_content( &$result)
{
foreach($this->content as $elt)
{
$elt->export($result );
}
}
function &find_by_id($id )
{
if($this->get_id() == $id)
{
return $this;
}
else
{
$content = &$this->get_content( );
foreach(array_k eys($content) as $key)
{
$elt = &$content[$key];
$result = &$elt->find_by_id($id );
if($result != null)
{
return $result;
}
}
return null;
}
}
function remove_content_ by_id($id)
{
$save_content = $this->get_content( );
$this->content = array();
foreach(array_k eys($save_conte nt) as $key)
{
$elt = &$save_conte nt[$key];
if($id != "all" && $elt->get_id() != $id )
{
$this->add($elt);
}
}
}
}
?>
Comment