2

Can you use shared memory between a PHP script and a C/C++ program in Windows? For instance, by using PHP shared memory (link) and windows memory mapped files?

AGB86
  • 21
  • 2
  • It would be very useful for everyone if you could elaborate more and give some supporting quotes and examples. – Blip May 16 '15 at 10:28

2 Answers2

0

I think that it may be possible if you create your own PHP extension. As far as I know, PHP extensions are written in C language.

Probably, there are already some extensions written to do this thing.

UPD:

It looks like it is possible. Please, take a look at this chapter in official docs: http://php.net/manual/en/book.shmop.php. And here is some example: http://www.raspberry-projects.com/pi/programming-in-c/memory/shared-memory-between-c-application-and-php-web-server

UPD 2:

I'm not very familiar with shared memory and memory mapped files, but it looks like these questions are somehow similar to yours: Shared memory C++ - PHP and PHP - Access shared Memory created with C++.

Also, you might be interested to read a book "Advanced PHP Programming" by George Schlossnagle (link). It looks like there is an example of how to implement a PHP extension to work with memory-mapped files.

Community
  • 1
  • 1
DWand
  • 674
  • 7
  • 16
0

Yes, it is possible. Starting from the links above I have been able to write a PHP extesion and a simple program which share the same Named Shared Memory.

AGB86
  • 21
  • 2