"Call-time pass-by-reference has been deprecated"

This is a discussion on "Call-time pass-by-reference has been deprecated" within the PHP Language forums, part of the PHP Programming Forums category; r_ahimsa_m@poczta.onet.pl wrote: > Hello, > > I am learning PHP5. I need to parse XML file and ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-21-2008
Rik Wasmus
 
Posts: n/a
Default Re: "Call-time pass-by-reference has been deprecated"

r_ahimsa_m@poczta.onet.pl wrote:
> Hello,
>
> I am learning PHP5. I need to parse XML file and I found a solution in some
> book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others).
> Unfortunately I have two problems that I don't understand:
>
> Warning: Call-time pass-by-reference has been deprecated; If you would like
> to pass it by reference, modify the declaration of xml_set_object(). 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.
> in /home/robert/public_html/rozgloszenia/bookparse.php on line 20
> Parse error: syntax error, unexpected ';', expecting T_FUNCTION
> in /home/robert/public_html/rozgloszenia/bookparse.php on line 100



> xml_set_object($this->parser, &$this); // HERE PROBLEM


Yup, just use xml_set_object($this->parser, $this);, the reference to
the second parameter rather then the value should be declared in the
funcion.

> }; // HERE PROBLEM


Braces ({}) for constructs like clasess, functions, and control
structures should bever end with ;

--
Rik Wasmus
....spamrun finished
Reply With Quote
  #2 (permalink)  
Old 05-21-2008
Iván Sánchez Ortega
 
Posts: n/a
Default Re: "Call-time pass-by-reference has been deprecated"

r_ahimsa_m@poczta.onet.pl wrote:

> Hello,
>
> I am learning PHP5. I need to parse XML file and I found a solution in
> some book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others).
> Unfortunately I have two problems that I don't understand:
>
> Warning: Call-time pass-by-reference has been deprecated;


It means that this is wrong:

<?php
function foo($bar) { ... }
foo(&$baaz);
?>

And this is right:

<?php
function foo(&$bar) { ... }
foo($baaz);
?>


> Parse error: syntax error, unexpected ';', expecting T_FUNCTION
> in /home/robert/public_html/rozgloszenia/bookparse.php on line 100


That means that you missed a "}" in the show_menu() function, check it out.
I'd suggest you to use an editor capable of keeping track of nested
parenthesis.


Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

La palabra es libre; la acción, muda; la obediencia, ciega.- J. Schiller
Reply With Quote
  #3 (permalink)  
Old 05-21-2008
r_ahimsa_m@poczta.onet.pl
 
Posts: n/a
Default "Call-time pass-by-reference has been deprecated"

Hello,

I am learning PHP5. I need to parse XML file and I found a solution in some
book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others).
Unfortunately I have two problems that I don't understand:

Warning: Call-time pass-by-reference has been deprecated; If you would like
to pass it by reference, modify the declaration of xml_set_object(). 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.
in /home/robert/public_html/rozgloszenia/bookparse.php on line 20
Parse error: syntax error, unexpected ';', expecting T_FUNCTION
in /home/robert/public_html/rozgloszenia/bookparse.php on line 100

<html>
<head>
<title>Moja biblioteczka</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
class BookList
{
var $parser;
var $record;
var $current_field = '';
var $field_type;
var $ends_record;
var $records;

function BookList($filename)
{
$this->parser = xml_parser_create();
xml_set_object($this->parser, &$this); // HERE PROBLEM
xml_set_element_handler($this->parser, 'start_element', 'end_element');
xml_set_character_data_handler($this->parser, 'cdata');
$this->field_type = array('title' => 1,
'author' => 2,
'isbn' => 1,
'comment' => 1);
$this->ends_record = array('book' => true);
$x = join("", file($filename));
xml_parse($this->parser, $x);
xml_parser_free($this->parser);
}

function start_element($p, $element, &$attributes)
{
$element = strtolower($element);
if ($this->field_type[$element] != 0)
{
$this->current_field = $element;
}
else
{
$this->current_field = '';
}
}

function end_element($p, $element)
{
$element = strtolower($element);
if ($this->ends_record[$element])
{
$this->records[] = $this->record;
$this->record = array();
}
$this->current_field = '';
}

function cdata($p, $text)
{
if ($this->field_type[$this->current_field] === 2)
{
$this->record[$this->current_field][] = $text;
}
elseif ($this->field_type[$this->current_field] === 1)
{
$this->record[$this->current_field] .= $text;
}
}

function show_menu()
{
echo "<table border=1>\n";
foreach ($this->records as $book)
{
echo "<tr>";
$authors = join(', ', $book['author']);
printf("<th><a href='%s'>%s</a></th><td>%s</td></tr>\n",
$_SERVER['PHP_SELF'] . '?isbn=' . $book['isbn'],
$book['title'],
$authors);
echo "</tr>\n";
}

function show_book($isbn)
{
foreach ($this->records as $book)
{
if ($book['isbn'] !== $isbn)
{
continue;
}
$authors = join(', ', $book['author']);
printf("<b>%s</b> autor: %s.<br>", $book['title'], $authors);
printf("ISBN: %s<br>", $book['isbn']);
printf("Komentarz: %s<p>\n", $book['comment']);
}
?>
Powrót do <a href="<?= $SERVER['PHP_SELF'] ?>">listy książek</a>.<p>
<?
}
}; // HERE PROBLEM

$my_library = new BookList("books.xml");
if ($_GET['isbn'])
{
$my_library->show_book($_GET['isbn']);
}
else
{
$my_library->show_menu();
}
</body>
</html>

Could you help me plase?
Thanks a lot!
/RAM/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:12 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0