I am getting following error with PHP 5.1.6:
Fatal error: Declaration of Tl1Telnet::ExecuteCommand() must be compatible with that of telnet::ExecuteCommand()
ExecuteCommand is implemented correctly defined in interface.
interface telnet {
public function DoTelnet();
public function ExecuteCommand($command,$fh);
}
class Tl1Telnet implements telnet{
public function ExecuteCommand($command,$fh = NULL){
fputs($this->socketResource,$command);
sleep(2);
$tl1_string = fread($this->socketResource,30000);
if($fh != NULL){
fwrite( $fh, $tl1_string );
}
return $tl1_string;
}
}
try removing
$fh = NULLfrom the implementation. that may be causing the problem. as the error clearly statesDeclaration of Tl1Telnet::ExecuteCommand() must be compatible with that of telnet::ExecuteCommand()i am not sure for what reason the error is being generated. you should probably upgrade your PHP version if you can, if not then try using the workaround demonstrated below.
Example.
in your interface set the argument to empty.
and in the derived class.
if the first argument is empty it will throw an error. if not it will fetch the first argument and assign it to $command variable. and if it finds the second argument then it will assign it to
$fhvariable if empty then assign the default value of NULL.