Hi, Im having some trouble with one line of this code im trying out, I cant seem to find the problem.
error message:
Content-type: text/html
X-Powered-By: PHP/5.0.0b3
<br />
<b>Parse error</b>: parse error, unexpected T_IF in <b>C:\phpxm\new.php</b> on line <b>21</b><br />
code:
<?
set_time_limit (0);
$address = '127.0.0.1';
$port = 3877;
$max_clients = 10;
$clients = Array();
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Could not bind to address');
socket_listen($sock);
while (true) {
$read[0] = $sock;
for ($i = 0; $i < $max_clients; $i++) {
if ($client[$i]['sock'] != null) {
$read[$i + 1] = $client[$i]['sock'];
}
}
$ready = socket_select($read,null,null,null)
if (in_array($sock, $read)) {
for ($i = 0; $i < $max_clients; $i++) {
if ($client[$i]['sock'] == null) {
$client[$i]['sock'] = socket_accept($sock);
break;
} elseif ($i == $max_clients - 1) {
print ("too many clients")
}
}
if (--$ready <= 0)
continue;
}
for ($i = 0; $i < $max_clients; $i++) {
if (in_array($client[$i]['sock'] , $read)) {
$input = socket_read($client[$i]['sock'] , 1024);
if ($input == null) {
unset($client[$i]);
}
$n = trim($input);
if ($input == 'exit') {
socket_close($client[$i]['sock']);
} elseif ($input) {
$output = ereg_replace("[ \t\n\r]","",$input).chr(0);
socket_write($client[$i]['sock'],$output);
}
} else {
socket_close($client[$i]['sock']);
unset($client[$i]);
}
}
}
socket_close($sock);
?>