Php chat room technology-implementation of confidential discussion

Source: Internet
Author: User
Each chat room provides a chat function to facilitate those chat friends who need to communicate privately. here we will introduce the methods for implementing private chat in my chat room as follows: 1. process each message

Each chat room provides a chat function to facilitate those chat friends who need to communicate privately. here we will introduce the methods for implementing private chat in my chat room as follows:

1. processing of sent information

Every private chat is displayed on the screen of the user and the private chat object, and others cannot see it. here, we will process the speech content and save it in the speech file!

  1. // $ Split is the separator
  2. Messagesend. php
  3. // Determine whether to speak privately
  4. If ($ secret = "on ")
  5. {
  6. // Mark the speech + Indicates the delimiter.
  7. // The first one marked as secret indicates private chat, followed by the chat object and its own name, so that the two can see
  8. $ Message =" Password $ message ";
  9. }
  10. Else
  11. {
  12. // If the first object is marked as "open", the object and its own name will be followed.
  13. $ Message =" $ Message ";
  14. }
  15. // Save it to the file
  16. ?>

2. private chat display method

Process and judge each new speech after reading it, and execute messageflush. php in the active refresh program.

  1. // Separate the speech content
  2. $ Tempmessage = split ($ split, $ message [0], 99 );
  3. // If the speaker is not a private conversation, or the target user is a private chat, or the user who sends the private chat is himself, this sentence is displayed; otherwise, it is not displayed.
  4. If ($ tempmessage [1]! = "Secret") | ($ tempmessage [2] = $ name) | (
  5. $ Tempmessage [3] = $ name ))
  6. {
  7. // Display private chat
  8. Print ("parent.u.doc ument. writeln (" $ message [0] ");");
  9. }
  10. ?>

This simple method enables private chat.

Note:Before saving the file for processing, there are In this way, you don't have to deal with it on the screen!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.