imrulhasan273
1 month ago
199
2
Laravel

How can I make a conditional variable in PHP?

Posted 1 month ago by imrulhasan273
$AJAXproducts = $products;

Here I get the $AJAXproducts = $products; and $products value is an array of data. But sometimes the $products is undefined for some pages. So for those pages I want something like below

$AJAXproducts = $products : [];

I want something that if products is not undefined then $AJAXproducts = $product else $AJAXproducts = [] and empty array

Please sign in or create an account to participate in this conversation.