- microtime: documentation ( source)
- strcmp: documentation ( source)
<?php
$v1 = 5;
$v2 = '5-4';
echo (strcmp($v1,$v2) === 0 ? 'they are the same' : 'they aren\'t the same');
$time = microtime(1);
$i = 0;
while($i++ < 50000) donull((strcmp($v1,$v2) === 0));
echo (microtime(1)-$time)." seconds for strcmp";
echo "\n";
$time = microtime(1);
$i = 0;
while($i++ < 50000) donull(((string) $v1 == (string) $v2));
echo (microtime(1)-$time)." seconds for typecasting";
function donull($v){};