Required PHP version - 5!

Recommend this page to a friend!

      PHP Serial  >  All threads  >  Required PHP version - 5!  >  (Un) Subscribe thread alerts  
Subject:Required PHP version - 5!
Summary:using non-php4-compliant funcs
Date:2008-10-29 10:00:29

  1. Required PHP version - 5!   Reply   Report abuse  
Picture of Yar Yar - 2008-10-29 10:00:29
First I want to thank you Remy for such a nifty tool for serial communication. It appeared extremely useful for me. Though there are problems when running it on PHP 4.4.8:

- syntax error, unexpected '=', expecting ')' in /usr/local/nginx/html/_test/php_serial.class.php on line 559

The report about this one was already posted in this forum. A possible workaround is to declare the function this way:

function _exec($cmd, $out = null)

and in cases where 2 arguments are neded call it with ampersand (&) before the 2nd parameter:

_exec("some_command", &$out);

- PHP Fatal error: Call to undefined function: stream_get_contents() in /usr/local/nginx/html/_test/php_serial.class.php on line 568

Obviously stream_get_contents() appeared only in PHP5. To make it work on PHP4 you can do the same like this:

$ret = ' ';
while ( !feof($pipes[1]) ) {
$ret .= fread($pipes[1], 1024);

PS. If you're not interested in making your class php4-compliant, please, change the prerequisite php version to 5.

For more information send a message to info at phpclasses dot org.