 |
|
 |
|
Next: postgresql and binary data
|
| Author |
Message |
External

Since: May 21, 2008 Posts: 12
|
(Msg. 1) Posted: Wed May 21, 2008 6:34 am
Post subject: "Call-time pass-by-reference has been deprecated" Archived from groups: comp>lang>php (more info?)
|
|
|
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/ >> Stay informed about: ""Call-time pass-by-reference has been deprecated"" |
|
| Back to top |
|
 |  |
External

Since: Apr 24, 2008 Posts: 44
|
(Msg. 2) Posted: Wed May 21, 2008 6:34 am
Post subject: Re: "Call-time pass-by-reference has been deprecated" [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
r_ahimsa_m.TakeThisOut@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 >> Stay informed about: ""Call-time pass-by-reference has been deprecated"" |
|
| Back to top |
|
 |  |
External

Since: Dec 27, 2007 Posts: 146
|
(Msg. 3) Posted: Wed May 21, 2008 6:34 am
Post subject: Re: "Call-time pass-by-reference has been deprecated" [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
r_ahimsa_m.RemoveThis@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 >> Stay informed about: ""Call-time pass-by-reference has been deprecated"" |
|
| Back to top |
|
 |  |
| Related Topics: | Call-time pass-by-reference has been deprecated; - Hi all, I have this kind of warning and would like to have it solved: Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of xml_parse_into_struct(). If you would like to enable..
Pass by reference question - I am creating a program to create sudoku games. I have an object that is 1 row of a sudoku game. I store the initial state of the row before I start figuring out the values to place in each cell, in case the program runs into a problem and has to rever...
Pass by reference via 'return' a variable... - Hi all, Quick question: If I have a function which populates a large array (ie. reading rowsets), is it better to pass in a reference to a variable to accept the data, or should I just create, populate and return the array from the function? Thanks in....
well...don't use any reference variable, how to call this .. - $stdObject->sayHi = create_function('', 'print "Hi";'); How to call sayHi without do something like: $sayHi = & $stdObject->sayHi; $sayHi(); Any good idears?or no idear.
Making Webservice call (SOAP Client) Call Using PHP. - Hi, I am new to php.I am trying to make a Webservice call thru php. The method requires XML as input. On the webservice logs its saying Blank Input.Any ideas why XML i built is not going thru the call. Any help will be greatly appreciated. Thanks in.... |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|