If you retrieve the value from the database and determine whether it is null, it looks very simple. You only need to compare it with null. Otherwise, if ($ objnull) {} will return an error in this case: notice: Tryingtogetpropertyofnon-objectproblem. Check whether the following code is required: if (isset ($ obj) {e
Retrieve the value from the database and determine whether it is null. This looks very simple. You only need to compare it with null. In fact, if ($ obj = null) {} in this case, an error will be reported: Notice: Trying to get property of non-object problem. After checking, we found that the following method is required: if (isset ($ obj) {e
If it is null after the value is retrieved from the database, it looks very simple. You only need to compare it with null. In fact, it is not,
if($obj==null){ }
In this case, the following error occurs: Notice: Trying to get property of non-object problem,
I checked and found that the following statement is required:
if (isset($obj)) { echo "This var is set set so I will print."; }
What is this isset?
The isset function checks whether variables are set.
Format: bool isset (mixed var [, mixed var [,...])
Return Value:
If the variable does not exist, FALSE is returned.
If the variable exists and its value is NULL, FALSE is returned.
If the variable exists and the value is not NULL, true is returned.
When multiple variables are checked at the same time, TRUE is returned only when each individual item meets the previous requirement; otherwise, the result is FALSE.
If unset () is used to release a variable, it will no longer be isset (). If you use isset () to test a variable that is set to NULL, FALSE is returned. Note that a NULL byte ("\ 0") is not equivalent to the NULL constant of PHP.
Warning: isset () can only be used for variables, because passing any other parameter will cause a parsing error. To check whether a constant has been set, use the defined () function.
It seems that the problem with my judgment just now is that "it is a NULL byte (" \ 0 ") and not equivalent to the NULL constant of PHP ".