on 4/10/04 13:34, Christian Schneider at [EMAIL PROTECTED] wrote: > I dare to disagree. For tool functions it often makes sense to make them > statically callable while you still might want to use them in an object > instance context respecting the instance's state. It may seem a bit > hacky but I like PHP for being dynamic enough to allow this.
In this case I was writing a 'delete' method that would either delete the current object's database record, or if passed an ID and called statically (hence the need to detect it), the record corresponding to that id. > He is asking for a mechanism to properly determine the static/non-static > status of a call and I assume he also suggests to add such a mechanism > in case it doesn't exist so I think your answer should be less hostile > as it concerns internals IMHO. I asked on internals because although this appears as a user-level problem, knowing the definitive answer requires knowledge of PHP internals. on 4/10/04 14:09, Wez Furlong at [EMAIL PROTECTED] wrote: > It is *not* ok to have a static method try and work like a non static method. > In PHP 5, declaring a static method will prevent $this from being initialized. > static means static. Take this as a hint that what you're trying to > do it wrong :-) If $this is always cleared in a static method, there really is no way of telling of the call was originally made statically or not (even introspection can only tell you how it's supposed to be, not how it actually happened). Anyway, I guess this is academic in PHP5, but it's still a concern in PHP4. > If you want to hack around the guts and do unsupported stuff like > this, be prepared for your code to break in future versions of PHP. > *cough* gallery assigning to $this *cough* I ran into that one back in early dev releases of PHP5 and improved my habits accordingly! To summarise, you can't tell, and you shouldn't be trying to anyway. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php