Re: PHP Script/Thread ID thingie

From: Date: Fri, 15 Aug 2008 22:36:22 +0000
Subject: Re: PHP Script/Thread ID thingie
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-278203@lists.php.net to get a copy of this message
On 15 Aug 2008, at 23:30, Richard Lynch wrote:
On Fri, August 15, 2008 10:52 am, Stut wrote:
On 15 Aug 2008, at 16:37, ceo@l-i-e.com wrote:
I'm logging things with error_log, and would like to be able to sort out one script run from another. So I'm looking for some kind of "script id" or "thread id" or "PHP script run execution ID" type of function. getmypid() just returns the same apache child process ID all the time, so that's not what I want. zend_thread_id() looks useful, but I suspect it's not quite what I'm looking for. But I'd have to re-compile with ZTS and --debug-mode and I don't think the function I'm looking for should require that... Perhaps I've just missed the right function name? Or perhaps this should be a "Feature Request"?
Don't think there is such a thing, but you could generate one by combining the pid, timestamp and the script filename, maybe into an md5 hash value or similar. Thinking about it, "ip.pid" would be enough, i.e. 127.0.0.1.12345.
The IP and pid will not actually change... It's just me surfing to my own app (or one I inherited) on my own desktop. Apache isn't getting nearly exercised enough to need a second child, so the pid is the same all the time... Guess I'll have to create one as Eric Butera suggested... Seems kind of odd that there isn't some kind of script/thread/M_INIT/R_INIT id hanging around and exposed that developers could use. [shrug]
I don't find that odd since there's on external context to such an ID other than that which you create within the script so you can just use something randomly unique. -Stut -- http://stut.net/

« previous php.general (#278203) next »