![PHP Error : Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` [duplicate]](https://omiddarvishi.ir/wp-content/uploads/2021/09/Screenshot-4.png)
آیا شما هم با این ارور کذایی مواجه شدید؟!
برای رفع این باگ باید کار زیر را انجام دهید
در php ورژن 7 یه اپراتور جدید با نام ?? بوجود اومده که کارش رو در نمونه کد زیر میتونید مشاهده کنید
<!--?php
// fetch the value of $_GET['user'] and returns 'not passed'
// if username is not passed
$username = $_GET['username'] ?? 'not passed';
print($username);
print("<br/-->");
// Equivalent code using ternary operator
$username = isset($_GET['username']) ? $_GET['username'] : 'not passed';
print($username);
print("<br>");
// Chaining ?? operation
$username = $_GET['username'] ?? $_POST['username'] ?? 'not passed';
print($username);
?>
حالا این ارور برای چیه؟
- 1- ورژن php شما 7به بعد نیست و دارید از ?? استفاده میکنید
- 2-یه جایی توی کدتون که از if else استفاده کردید باید از پرانتز هم استفاده کنید که نکردید
متن کامل ارور :
PHP Error : Unparenthesized
a ? b : c ? d : e
is deprecated. Use either(a ? b : c) ? d : e
ora ? b : (c ? d : e)
[duplicate]
منبع: Stackoverflow