Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6563163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:47:50+00:00 2026-05-25T13:47:50+00:00

I need to pass messages to my C program from PHP and I am

  • 0

I need to pass messages to my C program from PHP and I am doing this via message queues.

I have the message queues working and both sides can receive messages.

The problem is on the php side formatting the data. I am trying to send C style string, but php handles strings much differently. How would I convert the php string into a null temrinated C string?

Basically I need ‘config1’ to be the null terminated string.

msg_send($mq_id, $MSG_CHANGECONFIG, 'config1', true, false, $error);

It appears php stores strings like so: \”s:8:\\”config1\000\\”; where \ are just escapes.

Is there any way to do this, or a different way to parse this from the C side in order to convert it to a C string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:47:51+00:00Added an answer on May 25, 2026 at 1:47 pm

    You can try with

    $nullTerminatedString = sprintf("config1%c", 0);
    // or directly using escape sequence
    $nullTerminatedString = "config\0";
    echo strlen(sprintf("config1%c", 0)); # returns 8, so it should work
    

    Taken from here

    serialize
    The optional serialize controls how the message is sent.
    serialize defaults to TRUE which means that the message is serialized
    using the same mechanism as the session module before being sent to
    the queue. This allows complex arrays and objects to be sent to other
    PHP scripts, or if you are using the WDDX serializer, to any WDDX
    compatible client.

    So your call should be:

    msg_send($mq_id, $MSG_CHANGECONFIG, 'config1', **false**, false, $error);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass HTML code to messages and am doing so using templates.
I have a GNU C++ program and a python script that need to pass
I need to pass an array from JavaScript to a page method in C#.
I have an existing program where a message (for example, an email, or some
I need to have 2 (or maybe 3) continuously running facets of a program
I need to pass the response from ajax call to a jquery template.The response
In short : I have 2 windows applications(written using .NET) and need to pass
I am forwarding messages to some actual process controls from other process (This other
I have a TCP client-server setup where I need to be able to pass
I am receiving messages from the network on a non-GUI thread and need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.