array Validation errors list /** * Constructor, no parameters. */ public function __construct() { parent::__construct($this->host, 443, $this->timeout); } /** * HTML Document * * Returns an HTML document from a $fragment. * * @param string $fragment HTML content * @return string */ public function getDocument($fragment) { return '' . "\n" . '' . "\n" . '
' . "\n" . 'The document validates according to the specified schema(s).
')) { return true; } else { if ($errors = preg_match('#(There were errors.
#msU', $result, $matches)) { $this->html_errors = strip_tags($matches[1], '');
}
return false;
}
}
/**
* Validation Errors
*
* @return array HTML validation errors list
*/
public function getErrors()
{
return $this->html_errors;
}
/**
* Static HTML validation
*
* Static validation method of an HTML fragment. Returns an array with the
* following parameters:
*
* - valid (boolean)
* - errors (string)
*
* @param string $fragment HTML content
* @param string $charset Document charset
* @return array
*/
public static function validate($fragment, $charset = 'UTF-8')
{
$o = new self;
$fragment = $o->getDocument($fragment, $charset);
if ($o->perform($fragment, $charset)) {
return ['valid' => true, 'errors' => null];
} else {
return ['valid' => false, 'errors' => $o->getErrors()];
}
}
}
/** @cond ONCE */
}
/** @endcond */