PHP Warning: Attempt to read property
-
[26-Feb-2026 14:09:29 UTC] PHP Warning: Attempt to read property “success” on null in
\wp-content\plugins\simple-banner\simple-banner.php on line 552
Version 3.2.1
json_decode($result)is returning null, so$jsonis null — and you’re trying to read$json->success.In PHP 8+, accessing a property on
nullthrows this warning.$json = json_decode($result);
// 2026-02-27, gwb, fix php warning Attempt to read property "success" on null
$success = (is_object($json) && property_exists($json, 'success'))
? $json->{'success'}
: null;
//$success = $json->{'success'};
is_object($json)
makes sure json_decode($result) didn’t return null or something invalid
property_exists($json, 'success')
makes sure the success property is present
? $json->{'success'} : null
if both checks pass, use the value
otherwise, set $success to null
compatible with PHP 8.x (and also works in PHP 7.x).
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.