Parse error: syntax error, unexpected T_OBJECT_OPERATOR

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fairyprincess18
Forum Newbie
Posts: 21
Joined: Sun Dec 07, 2008 8:54 pm

Parse error: syntax error, unexpected T_OBJECT_OPERATOR

Post by fairyprincess18 »

I'm getting the following error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR

I know its being generated by this line as a result of my web host using php 4 and not 5:

Code: Select all

 
<?php
if (!$skype->client()->isRunning()) {
  $skype->client()->start(true, true);
}
?>
 
Apparently Php 4 cannot handle this type of function call chaining.

One workaround is use a temp variable like this:

Code: Select all

 
<?php
$skype = client();
if (!client()->isRunning()) {
  $skype->client()->start(true, true);
}
?>
 
i realize this is probably not right, can anyone help?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Parse error: syntax error, unexpected T_OBJECT_OPERATOR

Post by requinix »

No, that's about right. Can't chain stuff together like that in PHP 4 so you're stuck with using a temporary variable or redesigning your objects.
Post Reply