Skip to content

Instantly share code, notes, and snippets.

@calpo
Created December 1, 2011 08:32
Show Gist options
  • Save calpo/1415010 to your computer and use it in GitHub Desktop.
Save calpo/1415010 to your computer and use it in GitHub Desktop.
空文字とかfalseとかnullとか確認
<?php
echo "target\tif \tisset\tempty\tis_num\t'' \t'0' \t0 \n";
array_map(function($var){
static $i = 0;
$type = array("''", "0", "'0'", "false", "null");
echo sprintf('% 6s',$type[$i++]) ."\t";
echo (($var) ? 'true' : 'false') ."\t";
echo (isset($var) ? 'true' : 'false') ."\t";
echo (empty($var) ? 'true' : 'false') ."\t";
echo (is_numeric($var) ? 'true' : 'false') ."\t";
echo (($var == '') ? 'true' : 'false') ."\t";
echo (($var == '0') ? 'true' : 'false') ."\t";
echo (($var == 0) ? 'true' : 'false') ."\n";
}, array('', 0, '0', false, null));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment