Client-Server model: Difference between revisions
From Artificial Neural Network for PHP
Line 10: | Line 10: | ||
/** |
/** |
||
* @param string $ |
* @param string $strUsername |
||
* @param string $ |
* @param string $strPassword |
||
* @return boolean |
* @return boolean |
||
*/ |
*/ |
||
protected function checkLogin($ |
protected function checkLogin($strUsername, $strPassword) |
||
{ |
{ |
||
// User-defined authentication by database for example |
// User-defined authentication by database for example |
||
return ($ |
return ($strUsername == 'username' && $strPassword == 'password'); |
||
} |
} |
||
Line 25: | Line 25: | ||
} |
} |
||
$ |
$objServer = new ANN_MyServer; |
||
</source> |
</source> |
||
Revision as of 12:56, 18 December 2008
Server implementation
require_once 'ANN/ANN_Loader.php';
class ANN_MyServer extends ANN_Server
{
// ****************************************************************************
/**
* @param string $strUsername
* @param string $strPassword
* @return boolean
*/
protected function checkLogin($strUsername, $strPassword)
{
// User-defined authentication by database for example
return ($strUsername == 'username' && $strPassword == 'password');
}
// ****************************************************************************
}
$objServer = new ANN_MyServer;
Client implementation
require_once 'ANN/ANN_Loader.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();