Skip to content

PHP isset() function unexpected behavior with empty strings and empty arrays. Demonstrates a potential pitfall when relying solely on isset() for checking variable existence and non-null values.

Notifications You must be signed in to change notification settings

Bug-Hunter-X/PHP-isset-function-empty-string-array-behavior-jvzbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

PHP isset() function Unexpected Behavior with Empty Strings and Empty Arrays

This repository demonstrates a subtle issue with PHP's isset() function. The isset() function is often used to check if a variable is set and is not NULL. However, its behavior can be surprising when dealing with empty strings ('') or empty arrays ([]).

The bug.php file contains code that exhibits this unexpected behavior. The bugSolution.php file shows a corrected version that addresses the issue.

This example highlights the importance of carefully considering the different cases when using isset() and the need for potentially more robust checks.

About

PHP isset() function unexpected behavior with empty strings and empty arrays. Demonstrates a potential pitfall when relying solely on isset() for checking variable existence and non-null values.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages