PHP scripts such as WordPress, phpBB, phpMyAdmin etc. operate in their own world without much inter-process communication, even if they are running on the same Apache server. php 스크립트와 같은 wordpress, phpbb, phpmyadmin 등 자신의 세계에서 작동하지 않고 훨씬 동안 - 프로세스 커뮤니케이션, 비록 그들은 동일한 아파치 서버에서 실행되고있습니다. However sometimes you need to have a seamless way to communicate between PHP scripts without deadlock or resource contention. 그러나 때로는 방법을 원활하게 의사 소통이 있어야합니다 교착 상태 또는 리소스 경합을 사이에 php 스크립트를하지 않고있습니다. This is where messaging becomes useful. 이것은 어디 메시징이 유용합니다. PHP allows you to easily communicate between scripts running on the same machine. php를 사용하면 동일한 컴퓨터에서 실행되는 스크립트를 사이에 쉽게 의사 소통합니다.

PHP provides a set of function for inter-process communication. php를 제공 - 프로세스 커뮤니케이 션 동안 일련의 기능을합니다. They are: 그들은 :

msg_get_queue — Create or attach to a message queue msg_get_queue - 메시지에 답장을 만들거나 대기열에 첨부
msg_receive — Receive a message from a message queue msg_receive - 메시지 대기열에서 메시지가 나타납니다
msg_remove_queue — Destroy a message queue msg_remove_queue - 파괴하는 메시지 대기열
msg_send — Send a message to a message queue msg_send - 대기열로 메시지를 보내려면 메시지를
msg_set_queue — Set information in the message queue data structure msg_set_queue - 메시지 대기열에 정보를 데이터 구조를 설정
msg_stat_queue — Returns information from the message queue data structure msg_stat_queue - 메시지 대기열에서 정보를 데이터 구조를 반환합니다

Let’s see an actual example with two scripts which communicate with each other. 실제 예제 스크립트를 보자있는 두 개의 서로 통신할합니다. Save the files (preferably with the given names) on your htdocs (/var/www/html on Linux) directory. 저장하고 파일 (권장과 주어진 이름)에서 귀하의 htdocs (/ 변수 / 오픈 / html에 리눅스) 디렉토리합니다. First run the msg_send.php to add message to the queue. 먼저 메시지를 대기열에 추가 msg_send.php를 실행합니다. Then run msg_receive.php to get the messages and display them. 를 실행하고 표시하는 그들의 메시지를 msg_receive.php합니다.


File: msg_send.php 파일 : msg_send.php
Notes: This file adds two message to the queue 참고 사항 :이 파일을 두 개의 메시지를 대기열에 추가


File: msg_receive.php 파일 : msg_receive.php
Note: This file receives the message and prints them. 참고 사항 :이 파일을받는 메시지와 지문이 그들을합니다.


The output from the first script will be similar to: 첫 번째 스크립트의 출력을 유사하게됩니다 :

 Array (     [msg_perm.uid] => 48     [msg_perm.gid] => 48     [msg_perm.mode] => 438     [msg_stime] => 1194961462     [msg_rtime] => 1194961436     [msg_ctime] => 1194961406     [msg_qnum] => 2     [msg_qbytes] => 16384     [msg_lspid] => 9474     [msg_lrpid] => 9472 ) 배열 ([msg_perm.uid] => 48 [msg_perm.gid] => 48 [msg_perm.mode] => 438 [msg_stime] => 1194961462 [msg_rtime] => 1194961436 [msg_ctime] => 1194961406 [msg_qnum] => 2 [msg_qbytes] => 16384 [msg_lspid] => 9474 [msg_lrpid] => 9472) 

The output from the second script will be similar to: 두 번째 스크립트의 출력을 유사하게됩니다 :

 This is message #1 Array (     [msg_perm.uid] => 48     [msg_perm.gid] => 48     [msg_perm.mode] => 438     [msg_stime] => 1194961462     [msg_rtime] => 1194961471     [msg_ctime] => 1194961406     [msg_qnum] => 1     [msg_qbytes] => 16384     [msg_lspid] => 9474     [msg_lrpid] => 9476 ) This is message #2 Array (     [msg_perm.uid] => 48     [msg_perm.gid] => 48     [msg_perm.mode] => 438     [msg_stime] => 1194961462     [msg_rtime] => 1194961471     [msg_ctime] => 1194961406     [msg_qnum] => 0     [msg_qbytes] => 16384     [msg_lspid] => 9474     [msg_lrpid] => 9476 ) 이것은 메시지를 # 1 배열 ([msg_perm.uid] => 48 [msg_perm.gid] => 48 [msg_perm.mode] => 438 [msg_stime] => 1194961462 [msg_rtime] => 1194961471 [msg_ctime] => 1194961406 [ msg_qnum] => 1 [msg_qbytes] => 16384 [msg_lspid] => 9474 [msg_lrpid] => 9476)이이 메시지를 # 2 배열 ([msg_perm.uid] => 48 [msg_perm.gid] => 48 [msg_perm합니다. 모드] => 438 [msg_stime] => 1194961462 [msg_rtime] => 1194961471 [msg_ctime] => 1194961406 [msg_qnum] => 0 [msg_qbytes] => 16384 [msg_lspid] => 9474 [msg_lrpid] => 9476)