PHPverse 2025

Voting

: min(seven, eight)?
(Example: nine)

The Note You're Voting On

Anonymous
14 years ago
Comparison using <> operators should be documented. Between two objects, at least in PHP5.3, the comparison operation stops and returns at the first unequal property found.

<?php

$o1
= new stdClass();
$o1->prop1 = 'c';
$o1->prop2 = 25;
$o1->prop3 = 201;
$o1->prop4 = 1000;

$o2 = new stdClass();
$o2->prop1 = 'c';
$o2->prop2 = 25;
$o2->prop3 = 200;
$o2->prop4 = 9999;

echo (int)(
$o1 < $o2); // 0
echo (int)($o1 > $o2); // 1

$o1->prop3 = 200;

echo (int)(
$o1 < $o2); // 1
echo (int)($o1 > $o2); // 0

?>

<< Back to user notes page

To Top