3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Verifies that a password matches a hash. This validator requires that * function password_verify() is available (it is implemented natively * since PHP 5.5.0). */ class Zefram_Validate_PasswordVerify extends Zend_Validate_Abstract { const EMPTY_HASH = 'passwordVerifyEmptyHash'; const INVALID = 'passwordVerifyInvalid'; /** * @var string */ protected $_hash; protected $_messageTemplates = array( self::EMPTY_HASH => 'No hash was provided to match against', self::INVALID => 'The password provided is invalid', ); /** * Constructor. * * @param string|array $options * @throws Zend_Validate_Exception */ public function __construct($options = null) { if (!function_exists('password_verify')) { throw new Zend_Validate_Exception('Function password_verify() is not callable. Please upgrade to PHP 5.5 or install userland implementation. Read more at http://php.net/manual/en/function.password-verify.php'); } if (is_string($options)) { $options = array('hash' => $options); } if (is_object($options) && method_exists($options, 'toArray')) { $options = $options->toArray(); } if ($options) { $this->setOptions((array) $options); } } /** * @param array $options * @return Zefram_Validate_PasswordVerify */ public function setOptions(array $options) { foreach ($options as $key => $value) { $method = 'set' . $key; if (method_exists($this, $method)) { $this->{$method}($value); } } return $this; } /** * @param string $hash * @return Zefram_Validate_PasswordVerify */ public function setHash($hash) { $this->_hash = (string) $hash; return $this; } /** * @return string */ public function getHash() { return $this->_hash; } /** * @param string $value * @return bool */ public function isValid($value) { $value = (string) $value; $this->_setValue($value); $hash = $this->getHash(); if (empty($hash)) { $this->_error(self::EMPTY_HASH); return false; } if (!password_verify($value, $hash)) { $this->_error(self::INVALID); return false; } return true; } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Class "Zend_Validate_Abstract" not found in /in/jffqZ:8 Stack trace: #0 {main} thrown in /in/jffqZ on line 8
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'Zend_Validate_Abstract' not found in /in/jffqZ:8 Stack trace: #0 {main} thrown in /in/jffqZ on line 8
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Fatal error: Class 'Zend_Validate_Abstract' not found in /in/jffqZ on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Fatal error: Class 'Zend_Validate_Abstract' not found in /in/jffqZ on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/jffqZ on line 49
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/jffqZ on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/jffqZ on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/jffqZ on line 10
Process exited with code 255.

preferences:
279.31 ms | 401 KiB | 452 Q