How to check whether a string is empty in PHP

2 Answers

0 votes
$s = "";

if (empty($sg)) {
  echo "Empty";
} else {
  echo "Not empty";
}




/*
run:

Empty

*/

 



answered Feb 22, 2021 by avibootz
0 votes
$s = "";

if (strlen($s == 0)) {
  echo "Empty";
} else {
  echo "Not empty";
}




/*
run:

Empty

*/

 



answered Feb 22, 2021 by avibootz

Related questions

8 answers 309 views
1 answer 156 views
3 answers 174 views
1 answer 91 views
3 answers 160 views
3 answers 202 views
...