<?php
class Fails {
private $dir;
public function __construct($dir) {
$this->dir = @opendir($dir); // Different resource everytime
}
}
var_dump(new Fails('/tmp') == new Fails('/tmp'));
// Actual failure
var_dump(opendir('/tmp') == opendir('/tmp'));
// This works, because no member variable with a different value is assigned
class Works {
private $dir;
public function __construct($dir) {
$this->dir = $dir;
}
}
var_dump(new Works('/tmp') == new Works('/tmp'));
<br />
<b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/r10A4</b> on line <b>4</b><br />
Process exited with code 255.
<br />
<b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/r10A4</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br />
<b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/r10A4</b> on line <b>4</b><br />
Process exited with code 255.