PHP Error :Array callback must have exactly two elements Laravel

Created At: 2023-10-16 21:12:20 Updated At: 2023-10-16 21:29:51

If you work with Laravel or PHP and you may encounter the below error

"error": "Array callback must have exactly two elements" laravel

Well,there could be many reasons  for this error. But from the error reporting we get that "A callback function was expecting two elements, but one or none was given to this callback function".

Here you see I am using $_SERVER directive on line 20. And I am passing HTTP_STRIPE_SIGNATURE. It's part of our PHP Stripe payment

In this case $_SERVER is being called like a method because I used () with $_SERVER(). But it should be [], which means $_SERVER[] takes array like value.

After I changed $_SERVER() to $_SERVER[] the error "PHP Error :Array callback must have exactly two elements Laravel" is gone.

Check out complete API building course with Laravel/PHP for free 


Add Reviews

Recommended Posts

Latest Posts

Subscribe our newsletter