How To Communicate Between PHP Scripts (Sample Source Code Included) كيفية التواصل بين مخطوطات بي. اتش. بى) وشملت عينة شفره المصدر)
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. بي. اتش. بى برمجيه مثل الكلمات phpBB ، وما تعمل phpmyadmin الخاصة بها في العالم دون الكثير من المشترك بين عملية الاتصال ، حتى لو كانت على التوالي على نفس الخادم اباتشي. However sometimes you need to have a seamless way to communicate between PHP scripts without deadlock or resource contention. ولكن في بعض الاحيان تحتاج ان يكون لديك طريقة للاتصال سلس بين مخطوطات بي. اتش. بي الى طريق مسدود او الموارد دون خلاف. This is where messaging becomes useful. وهنا يصبح من المفيد إرسال الرسائل. PHP allows you to easily communicate between scripts running on the same machine. بي. اتش. بى تتيح لك الاتصال بسهولة بين الكتابات التي تظهر على نفس الإله.
PHP provides a set of function for inter-process communication. بي. اتش. بى توفر وظيفة لمجموعة من بين عملية الاتصال. 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 الخاص بك) / فار / الشبكه العالمية / لغة تأشير النص الفائق على لينكس) دليل. 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) Filed under المقدم بمقتضى Enterprise Software المشاريع والبرامج , ، Headline News أهم الانباء , ، How To كيف , ، Open Source Software برامج المصدر المفتوح , ، PHP بي. اتش. بى , ، Programming البرمجه , ، Tech Note ملاحظه تقنيه , ، Web شبكة | |
| |
RSS 2.0 ار اس اس 2،0 | |
Trackback this Article | هذه المادة |
Email this Article ارسل هذه المادة
You may also like to read ويمكنك ايضا ان تقرأ |




May 6th, 2008 at 8:41 am السادس من ايار / مايو ، 2008 في الساعة 8:41
[...] can be used to store and retrieve data across processes. (...)يمكن ان تستخدم لتخزين البيانات واسترجاعها عبر العمليات. This is also another alternative way to communicate between php scripts. وهذا ايضا هو آخر وسيلة بديلة للاتصال بين مخطوطات بي. اتش. بى. Normally shared memory is used for caching frequently used data in memory for php scripts on the [...] عادة ما تستخدم الذاكرة المشتركة التخزين المؤقت للبيانات التي يكثر استخدامها في بي. اتش. بي الذاكرة للمخطوطات على [...]