Thursday, 3 October 2024

Isset(), empty(), and checking a variable for true behave in PHP

Key Differences:

Variable Stateisset()empty()$var == true
Unset/undefinedfalse (Notice)true (No Notice)Notice/Error
nullfalsetruefalse
"" (empty string)truetruefalse
falsetruetruefalse
0truetruefalse
1truefalsetrue
"0" (string "0")truetruefalse
truetruefalsetrue
Non-empty string "abc"true            falsetrue        
[]true            truefalse

 

 Thank you

No comments:

Post a Comment

Publish npm package

  Để publish   pav-kit  lên NPM, bạn hãy làm theo các bước dưới đây. Tôi đã tạo thêm file  index.js  để đảm bảo gói tin hợp lệ. Bước 1: Tạo ...