Table of Contents
Introduction
Whatever we see on our website, it is either saved within HTML or being fetched from a table. The HTML has a script file attached with it which calls backend, where SQL codes are written. These SQL codes interact with database. In this article we will learn how to check if the value of a key in an object is empty or not.
Syntax
if(isset($obj-><key>)){ // if value is there, true is returned and the pointer comes here }
How to check if the key in an object is empty or not
Suppose we have a use case where we need to check if the incoming value of a variable is empty and pass “failed” for the same. In this particular case, we will write given code:
if(isset($obj->status)){ $status = $obj->status; } else{ $status = 'failed'; }
0 Comments