Wednesday 15 June 2011

how to check if a concatenated method doesnt exist php -


I am writing a function that calls another class and gives it back so that I can get my methods < Code> $ this- & gt; MyUser () - & gt; GetUsername () ... now my question is:

Do I call me -> GetUsername () myUser () or failed to find the block? ...

That's because I want to use another class which is myUserExtended () and I was wondering if I had both of these inside the myUser () can be done in the path inside. So that if -> GetCity () is not myUser () in it, it automatically starts and uses another variable which is myUserExtended () .

Probably not possible, but it is worth asking.

  private function myUser ($ setMyUser = false) {if ($ setMyUser) {$ this- & gt; _myUser = $ SetMyUser; } If (empty ($ this-> $ _ myUser)) {$ this-> _myUser = UserQuery :: create () - & gt; FindPK ($ this-> variable ('userID')); } $$ Return- & gt; _UI; }   

Perhaps something like this will help:

  Class MyUserClass {Private $ _myUser; Public function myUser ($ setMyUser = false) {if ($ setMyUser) {$ this- & gt; _myUser = $ setMyUser; } If (empty ($ this-> $ _ myUser)) {$ this-> _myUser = UserQuery :: create () - & gt; FindPK ($ this-> variable ('userID')); } $ This return; // If you want to use the method, you will have to return the public work __call ($ name, $ arguments $ $) {$ ext = new myUserExtended (); $ Ext- & gt; $ Name ($ argument); Return $ ext; }} $ MyUser = new MyUserClass (); $ MyUser- & gt; MyUser () - & gt; GetCity ("New York"); // This is $ ext- & gt; GetCity (Array ("New York") will call    

No comments:

Post a Comment