Why do I want to do this ask? (Or if you don't ask, skip the rest of this post
I'm working on a class which is meant to provide an interface to easily add parallel processing to a script. I posted the class in the coding critique forum but then later realised that something important was missing from it, the ability to pass information to and from the child process!
So in a search for how to do this, the answer that I've found is Semaphore, http://ca.php.net/manual/en/ref.sem.php
With this set of functions I can set up a shared memory space for parent and child processes to both access and share information. But rather than identifying the different variables by a string semaphore requires integer identifiers.
What I would like to do is be able to say, in the child:
Code: Select all
$var = "myvar";
$value = "foo";
$id = str2id($var);
shm_put_var($shm, $id, $value);
Then later I want to be able to say, in the parent
Code: Select all
$var = "myvar";
$id = str2id($var);
$value = shm_get_var($shm, $id);
Code: Select all
define("myvar", 1);
define("myothervar", 2);
etc.....