This is a discussion on is it possible to determine method that calls other method ? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Is it possible to determine method that calls another method ? for example: class A { private function One() { // do something depending ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Is it possible to determine method that calls another method ?
for example: class A { private function One() { // do something depending on calling method } public function Two() { return $this->One(); } public function Three() { return $this->One(); } } Apart from including method (__METHOD__) in function call: $this- >One(__METHOD__) ? Pugi! |
|
|||
|
On 27 mrt, 13:15, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Pugi! wrote: > > Is it possible to determine method that calls another method ? > > for example: > > > class A { > > private function One() { > > // do something depending on calling method > > } > > > public function Two() { > > return $this->One(); > > } > > > public function Three() { > > return $this->One(); > > } > > } > > > Apart from including method (__METHOD__) in function call: $this- > >> One(__METHOD__) ? > > > Pugi! > > No, but why would you want to? If you want to do something different, > create a different method. > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstuck...@attglobal.net > ================== Class that can create, modify, delete, move a file (physical) and its extensive metadata (database). A validate method for the input (an array) will be different for each action, but not completely. The calling method could be the means to distinguish between them. Pugi! |
|
|||
|
Pugi! wrote:
> Is it possible to determine method that calls another method ? > for example: > > class A { > private function One() { > // do something depending on calling method > } > > public function Two() { > return $this->One(); > } > > public function Three() { > return $this->One(); > } > } > > Apart from including method (__METHOD__) in function call: $this- >> One(__METHOD__) ? > > Pugi! > No, but why would you want to? If you want to do something different, create a different method. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Pugi! wrote:
> On 27 mrt, 13:15, Jerry Stuckle <jstuck...@attglobal.net> wrote: >> Pugi! wrote: >>> Is it possible to determine method that calls another method ? >>> for example: >>> class A { >>> private function One() { >>> // do something depending on calling method >>> } >>> public function Two() { >>> return $this->One(); >>> } >>> public function Three() { >>> return $this->One(); >>> } >>> } >>> Apart from including method (__METHOD__) in function call: $this- >>>> One(__METHOD__) ? >>> Pugi! >> No, but why would you want to? If you want to do something different, >> create a different method. >> >> -- >> ================== >> Remove the "x" from my email address >> Jerry Stuckle >> JDS Computer Training Corp. >> jstuck...@attglobal.net >> ================== > > Class that can create, modify, delete, move a file (physical) and its > extensive metadata (database). A validate method for the input (an > array) will be different for each action, but not completely. The > calling method could be the means to distinguish between them. > > Pugi! > Then you should have different validate methods, and call the appropriate one. Your code will be much cleaner. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Pugi! wrote:
> Is it possible to determine method that calls another method ? > for example: > > class A { > private function One() { > // do something depending on calling method > } > > public function Two() { > return $this->One(); > } > > public function Three() { > return $this->One(); > } > } > > Apart from including method (__METHOD__) in function call: $this- >> One(__METHOD__) ? > > Pugi! You could pass the name of the caller (or whatever you want to identify the caller with) as a parameter. $this->One("Fred"); $this->One("Barney"); It would make more sense than a raw method name anyway. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|