HTML Validator (uses as backend)

public HtmlValidator\Validator::CHARSET_BIG5 = 'Big5'
public HtmlValidator\Validator::CHARSET_BIG5_HKSCS = 'Big5-HKSCS'
public HtmlValidator\Validator::CHARSET_EUC_JP = 'EUC-JP'
public HtmlValidator\Validator::CHARSET_EUC_KR = 'EUC-KR'
public HtmlValidator\Validator::CHARSET_GB18030 = 'GB18030'
public HtmlValidator\Validator::CHARSET_GBK = 'GBK'
public HtmlValidator\Validator::CHARSET_ISO_2022_JP = 'ISO-2022-JP'
public HtmlValidator\Validator::CHARSET_ISO_2022_KR = 'ISO-2022-KR'
public HtmlValidator\Validator::CHARSET_ISO_8859_1 = 'ISO-8859-1'
public HtmlValidator\Validator::CHARSET_ISO_8859_13 = 'ISO-8859-13'
public HtmlValidator\Validator::CHARSET_ISO_8859_15 = 'ISO-8859-15'
public HtmlValidator\Validator::CHARSET_ISO_8859_2 = 'ISO-8859-2'
public HtmlValidator\Validator::CHARSET_ISO_8859_3 = 'ISO-8859-3'
public HtmlValidator\Validator::CHARSET_ISO_8859_4 = 'ISO-8859-4'
public HtmlValidator\Validator::CHARSET_ISO_8859_5 = 'ISO-8859-5'
public HtmlValidator\Validator::CHARSET_ISO_8859_6 = 'ISO-8859-6'
public HtmlValidator\Validator::CHARSET_ISO_8859_7 = 'ISO-8859-7'
public HtmlValidator\Validator::CHARSET_ISO_8859_8 = 'ISO-8859-8'
public HtmlValidator\Validator::CHARSET_ISO_8859_9 = 'ISO-8859-9'
public HtmlValidator\Validator::CHARSET_KOI8_R = 'KOI8-R'
public HtmlValidator\Validator::CHARSET_SHIFT_JIS = 'Shift_JIS'
public HtmlValidator\Validator::CHARSET_TIS_620 = 'TIS-620'
public HtmlValidator\Validator::CHARSET_UTF_16 = 'UTF-16'
public HtmlValidator\Validator::CHARSET_UTF_8 = 'UTF-8'

Characters sets

  • var string
public HtmlValidator\Validator::CHARSET_WINDOWS_1250 = 'Windows-1250'
public HtmlValidator\Validator::CHARSET_WINDOWS_1251 = 'Windows-1251'
public HtmlValidator\Validator::CHARSET_WINDOWS_1252 = 'Windows-1252'
public HtmlValidator\Validator::CHARSET_WINDOWS_1253 = 'Windows-1253'
public HtmlValidator\Validator::CHARSET_WINDOWS_1254 = 'Windows-1254'
public HtmlValidator\Validator::CHARSET_WINDOWS_1255 = 'Windows-1255'
public HtmlValidator\Validator::CHARSET_WINDOWS_1256 = 'Windows-1256'
public HtmlValidator\Validator::CHARSET_WINDOWS_1257 = 'Windows-1257'
public HtmlValidator\Validator::CHARSET_WINDOWS_1258 = 'Windows-1258'
public HtmlValidator\Validator::DEFAULT_VALIDATOR_URL = ''

Default validator URL

  • var string
public HtmlValidator\Validator::PARSER_HTML = 'html'
public HtmlValidator\Validator::PARSER_HTML4 = 'html4'
public HtmlValidator\Validator::PARSER_HTML4TR = 'html4tr'
public HtmlValidator\Validator::PARSER_HTML5 = 'html5'
public HtmlValidator\Validator::PARSER_XML = 'xml'

Parser constants

  • var string
public HtmlValidator\Validator::PARSER_XMLDTD = 'xmldtd'
public __construct( $validatorUrl = ''self::DEFAULT_VALIDATOR_URL, $parser = 'html5'self::PARSER_HTML5)

Constructs a new validator instance

  • param string $validatorUrl
  • param string $parser
  • throws \UnknownParserException
public getCharset()

Get the charset to report to the validator

  • return string
public getParser()

Get the set parser type

  • return string
public setCharset( $charset)

Set the charset to report to the validator

  • param string $charset Charset name (defaults to 'utf-8')
  • return \Validator
public setHttpClient( $httpClient)

Set the HTTP client to use for requests

  • param \HttpClient $httpClient
  • return \Validator
public setParser( $parser)

Set parser to use for the given markup

  • param string $parser Parser name (use Validator::PARSER_*)
  • return \Validator Returns current instance
  • throws \UnknownParserException If parser specified is not known
public validate( $document, $charset = NULL)

Validate a complete document (including DOCTYPE)

  • param string $document HTML/XML-document, as string
  • param string $charset Charset to report (defaults to configured client charset)
  • return \Response
  • throws \ServerException
public validateDocument( $document, $charset = NULL)

Validate a complete document (including DOCTYPE)

  • param string $document HTML/XML-document, as string
  • param string $charset Charset to report (defaults to utf-8)
  • return \Response
  • throws \ServerException
public validateNodes( $nodes, $charset = NULL)

Validates a chunk of HTML/XML. A surrounding document will be created on the fly based on the formatter specified. Note that this can lead to unexpected behaviour:

  • Line numbers reported will be incorrect
  • Injected document might not be right for your use case

NOTE: Use validateDocument() whenever possible.

  • param string $nodes HTML/XML-chunk, as string
  • param string $charset Charset to report (defaults to configured client charset)
  • return \Response
  • throws \UnknownParserException
  • throws \ServerException
public validateUrl( $url, $options = [])

Validate a URL

  • param string $url The absolute URL to the document
  • param array $options Array of options: 'checkErrorPages' - Set to true if you want to validate pages that return status codes which is not in the 2xx range
  • return \Response
  • throws \ServerException
private $defaultCharset = 'UTF-8'

Default charset to report to the validator

  • var string
private $httpClient = NULL

Holds the HTTP client used to communicate with the API

  • var \HttpClient
private $nodeWrapper = NULL

Node wrapper tool

  • var \NodeWrapper
private $parser = NULL

Parser to use for validating

  • var string
private getContentTypeString( $mimeType, $charset)

Get a string usable for the Content-Type header, based on the given mime type and charset

  • param string $mimeType Mime type to use
  • param string $charset Character set to use
  • return string
private getMimeTypeForParser( $parser)

Get the correct mime-type for the given parser

  • param string $parser Parser name
  • return string
© 2024 Bruce Wells
Search Namespaces \ Classes