PHP Classes

File: chat_room.php

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Chat Observe   chat_room.php   Download  
File: chat_room.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Chat Observe
Observe the activity of a chat room
Author: By
Last change:
Date: 4 days ago
Size: 422 bytes
 

Contents

Class file image Download
<?php
namespace Chat;
require_once
'vendor/autoload.php';

use
Chat\Usuario;

$salaDeChat = new SalaDeChat();

$usuario1 = new Usuario("Alice");
$usuario2 = new Usuario("Bob");

$salaDeChat->anexar($usuario1);
$salaDeChat->anexar($usuario2);

echo
"Sala de chat iniciada. Digite mensagens para notificar os usuários.\n";

while (
true) {
   
$mensagem = readline("Mensagem: ");
   
$salaDeChat->novaMensagem($mensagem);
}