Empty string: Difference between revisions

Content deleted Content added
No edit summary
Line 340: Line 340:
say 'String is empty' unless $s.chars;
say 'String is empty' unless $s.chars;
say 'String is not empty' if $s.chars;</lang>
say 'String is not empty' if $s.chars;</lang>

=={{header|PHP}}==
<lang Php><?php

$str = ''; // assign an empty string to a variable

// check that a string is empty
if (empty($str)) { ... }

// check that a string is not empty
if (! empty($str)) { ... }

// we could also use the following
if ($str == '') { ... }
if ($str != '') { ... }

if (strlen($str) == 0) { ... }
if (strlen($str) != 0) { ... }</lang>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==