Client-Server model
From Artificial Neural Network for PHP
Server implementation
require_once 'ANN/ANN_Loader.php';
class ANN_MyServer extends ANN_Server
{
// ****************************************************************************
/**
* @param string $username
* @param string $password
* @return boolean
*/
protected function checkLogin($username, $password)
{
// User-defined authentication by database for example
return ($username == 'username' && $password == 'password');
}
// ****************************************************************************
}
$server = new ANN_MyServer;
Client implementation
require_once 'ANN/ANN_Network.php';
try
{
$network = new ANN_Network;
}
catch(Exception $e)
{
print 'Network could not be created';
exit;
}
$inputs = array(
array(0, 0),
array(0, 1),
array(1, 0),
array(1, 1)
);
$outputs = array(
array(0),
array(1),
array(1),
array(0)
);
$network->setInputs($inputs);
$network->setOutputs($outputs);
$network = $network->trainByHost('username', 'password', 'http://example.tld/ANN_Server.php');
if($network instanceof ANN_Network)
$network->printNetwork();