PHP IPC函数介绍消息队列

msg_get_queue — Create or attach to a message queue
msg_queue_exists — Check whether a message queue exists
msg_receive — Receive a message from a message queue
msg_remove_queue — Destroy a message queue
msg_send — Send a message to a message queue
msg_set_queue — Set information in the message queue data structure
msg_stat_queue — Returns information from the message queue data structure

#!/usr/bin/env php
<?php
$queue_id=10086; //定义一个队列id
if(!msg_queue_exists($queue_id)){ //检测队列id是否存在,即被使用
        $queue=msg_get_queue($queue_id);
}
//向消息队列发送消息
msg_send($queue,1,serialize(array('a'=>'hello world','name'=>'测试')));
//展示消息队列的统计信息
$queue_info=msg_stat_queue($queue);
print_r($queue_info);
//从消息队列中接收消息,消息是以引用的方式获取
msg_receive($queue,0,$msg_typei,1024,$msg,true,null,$error);
print_r(unserialize($msg));
msg_remove_queue($queue); //销毁消息队列
原文地址:https://www.cnblogs.com/xiazh/p/2783047.html