0

I'm implementing a Google reCHAPTCHA form and I guess the PHP version is 4 on the server, because I'm getting errors, like

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /web/htdocs/---SITE---/recaptchalib.php on line 7

So because it does not recognize the PHP 5-only protected keyword, I'm getting errors. Can someone help me resolve this. There is no PHP4 version for the recaptchalib.php? Or I can change the PHP headler in the .htaccess file, but if the server is not supporting it?

chris85
  • 23,846
  • 7
  • 34
  • 51
styven
  • 51
  • 1
  • 9
  • Why are you still using PHP 4? That version is very old, has had numerous bugs resolved, has had numerous performance additions, and should be considered dead. http://php.net/eol.php – chris85 Jun 03 '17 at 14:34
  • Is not my server! and is not my decision :( – styven Jun 03 '17 at 14:35
  • Tell whoever is running it to upgrade. This is just problem 1 of tons you will encounter, and if spam bots are your problem, wait until you run into malicious bots. – chris85 Jun 03 '17 at 14:36
  • So there is no other solution? – styven Jun 03 '17 at 14:38
  • 1
    No good solution, everything your going to do is a hack. You could modify the Google code to use PHP 4 functions (for example `fopen, fread, fclose` instead of `file_get_contents`), even that might fail though if they require some new technology that didn't exist in 2005ish when that was released. Editing the source code of an API is not good practice. – chris85 Jun 03 '17 at 14:43
  • I understand, but what to use instead of `private function _encodeQS($data)` ?? – styven Jun 03 '17 at 14:45
  • I agree here with @chris85 . And as for your last question in comments, you have to remove the `private` word and read this: https://stackoverflow.com/questions/2247092/how-to-make-a-class-property-private-in-php4/2247114#2247114 – Jorge Campos Jun 03 '17 at 15:00
  • I removed the `private` word and now I'm stuck on this code part: `$getResponse = $this->_submitHttpGet( self::$_siteVerifyUrl, array ( 'secret' => $this->_secret, 'remoteip' => $remoteIp, 'v' => self::$_version, 'response' => $response ) );` what I can change here to not getting the `Parse error: syntax error, unexpected ',', expecting '('` error? – styven Jun 03 '17 at 15:38
  • If I'm not mistaken, php 4 doesn't have this syntaxe: `self::` everything defined this way will break... – Jorge Campos Jun 03 '17 at 17:57

0 Answers0