PHP 8.5.0 Alpha 1 available for testing

Voting

: max(five, nine)?
(Example: nine)

The Note You're Voting On

ahamilton9
3 years ago
A quick test in 2022 on PHP 8.1 confirms there is still no need to micro-optimize NULL checks:

<?php

// Comparison Operator
$before = microtime(true);
$var = null;
for (
$i=0 ; $i<1000000000 ; $i++) {
if(
$var === null) {}
}
$after = microtime(true);
echo
' ===: ' . ($after - $before) . " seconds\n";

// Function
$before = microtime(true);
$var = null;
for (
$i=0 ; $i<1000000000 ; $i++) {
if(
is_null($var)) {}
}
$after = microtime(true);
echo
'is_null: ' . ($after - $before) . " seconds\n";

// ===: 4.1487579345703 seconds
// is_null: 4.1316878795624 seconds

<< Back to user notes page

To Top