Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

is it possible to determine method that calls other method ?
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!

Report this thread to moderator Post Follow-up to this message
Old Post
Pugi!
03-27-08 01:01 PM


Re: is it possible to determine method that calls other method ?
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- 
>
> 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
==================


Report this thread to moderator Post Follow-up to this message
Old Post
Jerry Stuckle
03-27-08 01:01 PM


Re: is it possible to determine method that calls other method ?
On 27 mrt, 13:15, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Pugi! wrote: 
> 
> 
> 
> 
> 
>
> 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!

Report this thread to moderator Post Follow-up to this message
Old Post
Pugi!
03-27-08 01:01 PM


Re: is it possible to determine method that calls other method ?
Pugi! wrote:
> On 27 mrt, 13:15, Jerry Stuckle <jstuck...@attglobal.net> wrote: 
>
> 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
==================


Report this thread to moderator Post Follow-up to this message
Old Post
Jerry Stuckle
03-27-08 01:01 PM


Re: is it possible to determine method that calls other method ?
Pugi! wrote:
> Is it possible to determine method that calls another method ?
use info from debug_backtrace()

But I think this is bad way. Try to rewrite your code to avoid this.

Report this thread to moderator Post Follow-up to this message
Old Post
Alexey Kulentsov
03-29-08 12:03 AM


Re: is it possible to determine method that calls other method ?
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- 
>
> 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Preventer of Work
03-29-08 09:04 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 01:34 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.