note 36859 added to function.getmypid

From: Date: Fri, 24 Oct 2003 21:49:36 +0000
Subject: note 36859 added to function.getmypid
Groups: php.notes 
Request: Send a blank email to php-notes+get-59261@lists.php.net to get a copy of this message
One good use for this is deciding on a concurrency-safe temporary file or directory name. You can be assured that no two processes on the same server have the same PID, so this is enough to avoid collisions. For example: $tmpfile = "/tmp/foo_".getmypid(); // Use $tmpfile... // Use $tmpfile... // Use $tmpfile... unlink ($tmpfile); If you are sharing /tmp over the network (which is odd....) then you can, of course, mix in the PHP server's IP address. ---- Manual Page -- http://www.php.net/manual/en/function.getmypid.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36859 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36859&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36859&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59261) next »