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 453 views
1 answer 220 views
3 answers 246 views
1 answer 167 views
3 answers 250 views
3 answers 283 views
...