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 439 views
1 answer 214 views
3 answers 240 views
1 answer 158 views
3 answers 244 views
3 answers 278 views
...