Client-Server model: Difference between revisions

From Artificial Neural Network for PHP
No edit summary
Line 7: Line 7:
class ANN_MyServer extends ANN_Server
class ANN_MyServer extends ANN_Server
{
{
/**
// ****************************************************************************
* @param string $strUsername
* @param string $strPassword
* @return boolean
*/


protected function checkLogin($strUsername, $strPassword)
/**
{
* @param string $strUsername
// User-defined authentication by database for example
* @param string $strPassword
* @return boolean
*/


protected function checkLogin($strUsername, $strPassword)
return ($strUsername == 'username' && $strPassword == 'password');
}
{
// User-defined authentication by database for example

return ($strUsername == 'username' && $strPassword == 'password');
}

// ****************************************************************************
}
}



Revision as of 21:05, 8 February 2011

Server implementation

require_once '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/Loader.php';

try
{
  $objNetwork = new ANN_Network;

  $objValues = new ANN_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 ANN_Network)
  $objNetwork->printNetwork();