Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
PHP function help
Hi,
I have this code:
<?php
echo "Function Test\n";
function connect($server, $port)
{
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if($connection = socket_connect($socket, $server, $port) < 0)
{
trigger_error("SOCKET FAILURE" . "\n");
exit(0);
}
}
function send($data)
{
socket_write($socket, $data);
}
connect("www.spinchat.com", 3001);
send("TEST");
exit(0);
?>
But when I run it, it says the variable $socket isn't defined, now I kind of know the problem here, but I've tried putting the method calls at the top, and the definitions at the bottom, and this way, but I can't get it to work. Does anyone know the standard way of writing function filled code? Like, the proper order….