1

I am using a Shared Memory block containing a C Struct from a C program and I wish to map it to PHP so that I can expose and manipulate the shared memory via a web interface. Any idea how I can do this considering that PHP doesn't have a struct operator?

Mark
  • 436
  • 4
  • 18
  • Seems like an ungodly thing to do, but surely you have your reasons. Once you have created your shared memory block, and most likely protected its concurrent access with a semaphore shared by your C and PHP code, you can read and write binary data with `shmop_read`/`shmop_write`, but PHP will see that as pure binary, so you'll have to use `pack`/`unpack` to process it to and from meaningful PHP variables. And you'll have to recreate the C data structures in PHP by hand. That would require a lot of code and debugging to work, but it's doable. And it won't work on a Windows PHP version either. – kuroi neko Mar 22 '15 at 21:38
  • Thankyou Kuroi. Yes I agree, it is possibly an ungodly thing to do, but one of the options I am considering. I suspect that this is do-able, but not worth the effort considering that there are easier ways to achieve the same goal. – Mark Mar 22 '15 at 23:12

0 Answers0