Client-Server model

From Artificial Neural Network for PHP
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Server implementation

require_once 'ANN/Loader.php';

use ANN\Server;

class MyServer extends 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 MyServer;

Client implementation

require_once 'ANN/Loader.php';

use ANN\Network;
use ANN\Values;

try
{
  $objNetwork = new Network;

  $objValues = new Values;

  $objValues->train()
            ->input(0,0)->output(0)
            ->input(0,1)->output(1)
            ->input(1,0)->output(1)
            ->input(1,1)->output(0);
}
catch(Exception $e)
{
  die('Network could not be created');
}

$objNetwork->setValues($objValues); // to be called as of version 2.0.6

$objNetwork = $objNetwork->trainByHost(
                             'username',
                             'password',
                             'http://example.tld/ANN_Server.php'
                             );

if($objNetwork instanceof Network)
  $objNetwork->printNetwork();