<?php function updateList($list) { $list[0] = 1; } function updateList2(&$list) { $list[0] = 1; } $val = array(0, 2); updateList($val); print "{$val['0']}\n"; updateList2($val); print "{$val['0']}\n";
<?php if (isset($_GET['update'])) { updateList($_GET['update'], $_GET['nb']); } if (isset($_GET['send'])) { $msg = $_GET['send']; $user = $_GET['user']; sendMessage($msg, $user); } function db() { // url du serveur $servername = "localhost"; // Nom d'utilisateur Base de données $username = "******"; // MDP utilisateur $password = ""; // Nom de la base de donnée $dbname = "websiteTest"; $co = mysqli_connect($servername, $username, $password, $dbname); mysqli_set_charset($co, "utf8mb4"); return $co; } // affiche la liste de tout les messages function updateList($user, $nbmessages) { $sql = "SELECT COUNT(*) FROM message"; $result = mysqli_query(db(), $sql); $result = mysqli_fetch_all($result)[0][0]; $DATA = ["new" => false, "message" => ""];