PHP Classes

Error Message in

Recommend this page to a friend!

      PHP Google Calendar Add Event  >  PHP Google Calendar Add Event package blog  >  How to Generate a PHP...  >  All threads  >  Error Message in  >  (Un) Subscribe thread alerts  
Subject:Error Message in
Summary:Used the program but a programming error message is returned
Messages:6
Author:martin butt
Date:2021-01-06 22:54:54
 

  1. Error Message in   Reply   Report abuse  
Picture of martin butt martin butt - 2021-01-06 22:54:54

The set of programs is uploaded to my server. I tried the example file AddEventExample.php from my browser and this error was returned by my server:

Got error 'PHP message: PHP Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in gcalendar-2020-12-17/SKien/Calendar/GCalAddEventLink.php on line 22\n

  2. Re: Error Message in   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2021-01-07 10:28:32 - In reply to message 1 from martin butt
Hi martin,

Obviously you are still using PHP in a version earlier than 5.3, in which the constant definition in a class with the keyword 'const' is not yet supported!

Since this package also uses type hints for function arguments, return values and class properties, PHP 7.4 is required (type hints for class properties are only supported since this version).

The PHP version required for this package is shown in the first line of the readme file.

regards, Stefan

  3. Re: Error Message in   Reply   Report abuse  
Picture of martin butt martin butt - 2021-01-07 23:20:36 - In reply to message 2 from Stefan Kientzler
Thanks for your response.
My server is using: PHP Version 7.0.33.

It does recognize classes but looks like not 'const'. Is there a workaround?

Martin

  4. Re: Error Message in   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2021-01-08 09:37:02 - In reply to message 3 from martin butt
OK,

The visibility specifier for constants is also only supported since PHP 7.1...

first recommendation is to upgrade from PHP 7.0 to 7.4 ;-)

If you can't (or won't) do so, you have to 'downgrade' the code of GCalAddEventLink.php by yourself:

1. remove the visibility specifiers from the const declarations:
-> delete the 'public' keyword before the 'const' specifier

2. remove all type hintings for the properties:
-> delete 'string'/'DateTime'/... in the declarations
(i.E. protected string $strXXX -> protected $strXXX)

3. remove all return type hints:
-> delete all ' : <type>' after the function declarations

4. change nullable parameter type hinting in the constructor:
-> remove the '?' before the LoggerInterface classname

regards Stefan



  5. Re: Error Message in   Reply   Report abuse  
Picture of martin butt martin butt - 2021-01-08 19:05:43 - In reply to message 4 from Stefan Kientzler
Thanks for your hints. I'll tackle those changes next week and retry the program. The server is not in my control so I have no ability to upgrade from PHP7.0 to PHP7.4.

Martin

  6. Re: Error Message in   Reply   Report abuse  
Picture of martin butt martin butt - 2021-08-06 14:50:19 - In reply to message 5 from martin butt
Update. This program works seamlessly now the server is using PHP7.4.11

Thank you for this useful code.