0

For example , I open 01.php in firefox , open 02.php in google chrome ,
01.php create a shared memory segment , now I 01.php write a msg to this shared memory segment ,
and I want 02.php to access this shared memory segement and read the msg .
can it be successed ? And how to do ?

I only know that if use read-write file instead of use shared memory , it can be successed .

2
  • 1
    Memcache(d) is a memory cache that is designed for distribution. You should give it a go, very easy to get started. Commented Jul 19, 2013 at 13:55
  • I smell a huge XY problem. You may want to explain what you actually want to achieve. Commented Jul 19, 2013 at 13:57

1 Answer 1

1

If sharing memory is really what you want to achieve use the APC extension.

01.php

<?php
$bar = 'SOME VALUE';
apc_store('myuniquekey', $bar);

02.php

var_dump(apc_fetch('myuniquekey'));

EDIT:

There's another way i wasn't aware of - without using apc: http://php.net/shmop. It is little more complex and ugly as you have to allocate space and stuff, but it is more likely that the shmop extension is available without beeing required to install it manually.

$shm_id = shmop_open(0x123, 'c', 0644, 250);
shmop_write($shm_id, "Data in shared memory", 0);
$value = shmop_read($shm_id, 8, 6);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.