By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,636 Members | 2,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,636 IT Pros & Developers. It's quick & easy.

T_OBJECT_OPERATOR error

P: n/a
<?
class foo {

var $value;
var $child = array();

function setChild($ch) {
array_push($this->child,$ch);
}

function getChild($i) {
return $this->child[$i];
}

function getValue() {
return $this->value;
}

}

$tp = new foo();
$row = new foo();

$row->setChild($tp);

$row->getChild(0)->getValue();

?>

When I run this script i get the error

Parse error: parse error, unexpected T_OBJECT_OPERATOR in \\path\to\file on line 26

on line "$row->getChild(0)->getValue();"

can someone help me out here..??

Thanx

Salil

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Salil Das | It's ok to kiss a fool,
bugs@cc | It's ok to let a fool kiss you,
| but never ever let a kiss fool you.
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Sat, 17 Apr 2004 22:05:55 +0000, bugs wrote:
<?
class foo {

var $value;
var $child = array();

function setChild($ch) {
array_push($this->child,$ch);
}

function getChild($i) {
return $this->child[$i];
}

function getValue() {
return $this->value;
}

}

$tp = new foo();
$row = new foo();

$row->setChild($tp);

$row->getChild(0)->getValue();

?>

When I run this script i get the error

Parse error: parse error, unexpected T_OBJECT_OPERATOR in \\path\to\file on line 26

on line "$row->getChild(0)->getValue();"

$a = $row->getChild(0);
$b = $a->getValue();

Regards,
Henk Burgstra
Jul 17 '05 #2

P: n/a
"bugs" <bu**@cc.gatech.edu> wrote in message
news:c5**********@solaria.cc.gatech.edu...
<?
class foo {

var $value;
var $child = array();

function setChild($ch) {
array_push($this->child,$ch);
}

function getChild($i) {
return $this->child[$i];
}

function getValue() {
return $this->value;
}

}

$tp = new foo();
$row = new foo();

$row->setChild($tp);

$row->getChild(0)->getValue();

?>


If you plan to program in this way, you're in for a world of hurt. Your
program probably won't behave the way you think it would, because all your
assignments are by copy and you're always returning copies of the child
objects.
Jul 17 '05 #3

P: n/a
Henk Burgstra <eg****@xs4all.nl> wrote:
On Sat, 17 Apr 2004 22:05:55 +0000, bugs wrote:

<?
class foo {

$a = $row->getChild(0);
$b = $a->getValue();

Ya, I came up with that, but, isnt there a way to do this like C style..
would be helpful rather than creating a new variable everytime..

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Salil Das | It's ok to kiss a fool,
bugs@cc | It's ok to let a fool kiss you,
| but never ever let a kiss fool you.
Jul 17 '05 #4

P: n/a
Salil Das schrieb:
Henk Burgstra <eg****@xs4all.nl> wrote:
On Sat, 17 Apr 2004 22:05:55 +0000, bugs wrote:

<?
class foo {

$a = $row->getChild(0);
$b = $a->getValue();

Ya, I came up with that, but, isnt there a way to do this like C style..


Use PHP 5.

Regards,
Matthias
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.