CFV5 Throwing PHP Error in PHP version 7.1

Resolve a PHP syntax error in ChronoForms v5 when upgrading to PHP 7.1.

Overview

The error occurs because newer PHP versions, like 7.1, no longer allow certain shorthand array declarations within function calls.
Update the array syntax in your form's DB event by declaring the array separately before using it, rather than defining it inline.

Answered
ChronoForms v5
an annekm 24 Apr, 2019
Hello,

When updating the PHP version of my server to 7.1, as recommended by Joomla, my ChronoformsV5 is throwing the following error

0 - syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'

Can you please let me know how to correct this issue? Is ChronoformsV5 compatible with PHP 7.1?

Thanks
Anu
Gr GreyHead 24 Apr, 2019
Hi Anu,

Have you updated to the latest release of CFv5?

Bob
an annekm 24 Apr, 2019
Hello,

My CFv5 version is 5.0.17.

I was debugging the php code in my form. The array push in the DB event was throwing the issue.

Changing the Condition parameter in the DB event as below seems to remove the error.

OLD CODE
$where = array(
'mememail' => $form->data['mememail']
);

NEW CODE

$where['mememail'] = $form->data['mememail'];
return $where;
Hope version is 5.0.17 is compatible with PHP 7.1.

Regards,
Anu
Gr GreyHead 24 Apr, 2019
Answer
Hi Anu,

There is a change in the newer PHP versions and iirc you can no longer define an array 'on the fly' instead it has to be declared as an array before it is used.

Bob
an annekm 24 Apr, 2019
Hi Bob,

Thanks. The change in the array declaration has rectified the issue.

Now the forms are working fine in PHP 7.1.

Regards,
Anu
This topic is locked and no more replies can be posted.