Support the ongoing development of Laravel.io →
posted 3 years ago

Hi I am using PHP 7.4 for a laravel application and I am getting this exception very frequently

Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

The code which triggers this exception is :

{{$gigData->three_packages == 1 ? 'checked' : $gigData->packages_details == null ? 'checked' : ''}} onchange="showPackage(this,{{json_encode($customFields->toArray())}})">

I don't know how I can solve it

any opinion???

thank you very much!!

Last updated 3 years ago.
0
moderator Solution

This usage has been deprecated since PHP 7.4: https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.nested-ternary

Either use:

($gigData->three_packages == 1 ? 'checked' : $gigData->packages_details == null) ? 'checked' : ''

Or:

$gigData->three_packages == 1 ? 'checked' : ($gigData->packages_details == null ? 'checked' : '')

Depending on what you want the logic to be.

joedixon liked this reply

1
Solution selected by @driesvints

Sign in to participate in this thread!

Eventy

Your banner here too?

Cristian zeus6999 Joined 31 Oct 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.