PHP Classes

File: ipcContainer.example1.php

Recommend this page to a friend!
  Classes of Matthew Knowlton   ipcContainer   ipcContainer.example1.php   Download  
File: ipcContainer.example1.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: ipcContainer
Share variables between tasks with shared memory
Author: By
Last change:
Date: 9 years ago
Size: 1,088 bytes


Class file image Download

//open two shared memory slots
$container1 = new ipcContainer('1234');
$container2 = new ipcContainer('4321');

//opening a pointer to the same ipcContainer as container2
//for testing purposes
$container3 = new ipcContainer('4321');

//write variable "test" differently into each slot
$container1->test = array('hello' => 'world');
$container2->test = 'hello world';
//this data is immediately available on any other process or any other container with the same id
//and can be immediately overwritten by another container with the same id
$container3->test = 'Goodbye planet!!!';

//show the stored data
//container1 will print the ['hello' => 'world']
echo '$container1 variable test set to '.print_r($container1->test,true).";<br/>";

//container2 will print 'Goodbye planet!!!'
//because it is accessing the same ipcContainer as container3
echo '$container2 variable test set to '.print_r($container2->test,true).";<br/>";
'$container3 variable test set to '.print_r($container3->test,true).";<br/>";