Created
March 5, 2021 19:29
-
-
Save tim-cotten/2ed837a4e083010750bbb3fa71537221 to your computer and use it in GitHub Desktop.
PHP Bugs: Property Problems (Example F)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... $desc should be a JSON string ... | |
if (!empty($desc)) { | |
try { | |
$desc_obj = json_decode($desc); | |
if (!is_object($desc_obj)) { | |
throw new Exception(); | |
} | |
$action = !empty($desc_obj->action) ? $desc_obj->action : 'none'; | |
$reasons = !empty($desc_obj->reasons) ? explode(',', $desc_obj->reasons) : array(); | |
} catch (Exception $e) { | |
$action = "none"; | |
$reasons = array(); | |
} | |
// ... parsing logic for $reasons ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment