|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-04-29 20:20 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 24 15:00:01 2025 UTC |
Description: ------------ I get Notice: Object of class File could not be converted to integer when trying to compare object contents using '==' comparison operator. Comparing the actual reference using === works, but obviously means something different. Reproduce code: --------------- class File { public $var; function __construct($val) { $this->var = $val; } } $t1 = new File("test"); $t2 = new File("test"); print_r($t1); print_r($t2); print "\$t1 == \$t2 ?"; if ($t1 == $t2) { print "YES\n"; } else { print "NO\n"; } Expected result: ---------------- File Object ( [var] => test ) File Object ( [var] => test ) $t1 == $t2 ? YES Actual result: -------------- File Object ( [var] => test ) File Object ( [var] => test ) $t1 == $t2 ? Notice: Object of class File could not be converted to integer in /var/www/apps/ddi/test.php on line 18 Notice: Object of class File could not be converted to integer in /var/www/apps/ddi/test.php on line 18 YES