473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

"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</bautor: %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/
Jun 2 '08 #1
2 2840
r_********@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
Jun 2 '08 #2
r_********@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
Jun 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ¤ Alias | last post by:
I have a function named getID3info (lvwDiscInfo.SelectedItem). What is the difference between getID3info (lvwDiscInfo.SelectedItem) and Call getID3info(lvwDiscInfo.SelectedItem) ?
7
by: William Morris | last post by:
So, what's the prevailing opinion regarding the use of the "CALL" keyword? I'm working with a third-party ASP application, adapting for our system, and the CALL keyword is used everywhere. I've...
2
by: Simon Wigzell | last post by:
What is the call? Better yet is there a link to a page that describes all the possible javascript calls to the various browser menu items and explains compatibility across different browsers?...
0
by: John | last post by:
Hi all, is there a way to call "Select Users or Groups" dialog from .NET? This is the dialog when you browse the users or groups on local computer or on Windows domain. Please advice. Thanks.
2
by: balg | last post by:
An ActiveX control has a call to "UserControl.Parent" which fails when it is interopped and added to a .Net Form. Is there any way to access to .Net parent control/it's interfaces from VB6...
13
by: Larry Menard | last post by:
Test code: $dbconn = odbc_connect($dbname, $username, $password); $path = "C:\Temp\myJar.jar"; $statement = "CALL SQLJ.INSTALL_JAR('file://$path', 'myJarId')"; $result = odbc_exec($dbconn,...
16
by: a | last post by:
Hi everybody, My config: Win XP (or 2003), Apache 2.0.54, PHP 5.1.2. I have been trying to handle the case of a lenghty opearation on the server while providing the user with feedback and...
10
by: Thorsten Ottosen | last post by:
Hi, I'm trying to escape html before its saved in a database. I tried $text = htmlentities( $reader->value ); but that don't work for e.g. japanese characters.
2
by: javelin | last post by:
I'm studying "Visual Basic Developer's Guid to ASP & IIS", and I am following instructions an pp 72-75. I am creating a WebClass, and enter code as instructed, and it all is entered correctly. ...
5
by: Frederick Gotham | last post by:
If we have a simple class such as follows: #include <string> struct MyStruct { std::string member; MyStruct(unsigned const i) {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.