This article mainly shares with you several methods of determining whether a variable is empty in PHP. I hope it can help you. Whether it is empty method

小云云
Release: 2023-03-21 16:00:02
Original
1393 people have browsed it

This article mainly shares with you several PHP methods to determine whether a variable is empty. I hope it can help you.

  • Use if()

$a=1;if($a)     值为true$a='a';
if($a)     值为true$a='';
if($a)     值为false$a=0;
if($a)     值为false$a=null;
if($a)     值为false
Copy after login
  • empty

$a=1;if(!empty($a))     值为true$a='a';
if(!empty($a))     值为true$a='';
if(!empty($a))     值为false$a=0;
if(!empty($a))     值为false$a=null;
if(!empty($a))     值为false
Copy after login
  • Comparison of several other functions
    This article mainly shares with you several methods of determining whether a variable is empty in PHP. I hope it can help you. Whether it is empty method

Related recommendations:

php determines variable type

Variable type Common methods for judging variable types in php

Common methods for judging variable types in php_PHP tutorial

The above is the detailed content of This article mainly shares with you several methods of determining whether a variable is empty in PHP. I hope it can help you. Whether it is empty method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!