calling member function in php 5

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
tedyu
Forum Newbie
Posts: 3
Joined: Wed Jun 10, 2009 5:44 pm

calling member function in php 5

Post by tedyu »

I use the following code to call member function:
_StoredProcs::$this->_serializerOptions['rootName']($this->AccountParams);

It works fine in php 4.

php 5 gave me fatal error:
Call to undefined function create() in ...

Has anyone else encounter this problem ?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: calling member function in php 5

Post by requinix »

We have absolutely no idea what you're talking about.
tedyu
Forum Newbie
Posts: 3
Joined: Wed Jun 10, 2009 5:44 pm

Re: calling member function in php 5

Post by tedyu »

_StoredProcs has member function create() among others.
$this->_serializerOptions['rootName'] holds the name of member function.

Such syntax is accepted by php 4.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: calling member function in php 5

Post by requinix »

Could be the precedence rules changed in PHP 5, but I'm not seeing any mention of :: or -> in the charts.

Try

Code: Select all

_StoredProcs::{$this->_serializerOptions['rootName']}($this->AccountParams);
tedyu
Forum Newbie
Posts: 3
Joined: Wed Jun 10, 2009 5:44 pm

Re: calling member function in php 5

Post by tedyu »

That produces:
[Wed Jun 10 10:23:33 2009] [error] [client 10.10.129.94] PHP Parse error: syntax error, unexpected '{', expecting T_STRING or T_VARIABLE or '$' in
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: calling member function in php 5

Post by requinix »

Guess it doesn't work statically (too lazy to test it myself).

As a quick sanity check,

Code: Select all

$function = $this->_serializerOptions['rootName'];
_StoredProcs::$function($this->AccountParams);
If, for some reason, that doesn't work,

Code: Select all

$function = array("_StoredProcs", $this->_serializerOptions['rootName']);
$function($this->AccountParams);
One of those should work. If not then you have other problems.
Post Reply