📄 ph5p.php
字号:
Switch to the attribute value (single-quoted) state. */
$this->state = 'attributeValueSingleQuoted';
} elseif($char === '>') {
/* U+003E GREATER-THAN SIGN (>)
Emit the current tag token. Switch to the data state. */
$this->emitToken($this->token);
$this->state = 'data';
} else {
/* Anything else
Append the current input character to the current attribute's value.
Switch to the attribute value (unquoted) state. */
$last = count($this->token['attr']) - 1;
$this->token['attr'][$last]['value'] .= $char;
$this->state = 'attributeValueUnquoted';
}
}
private function attributeValueDoubleQuotedState() {
// Consume the next input character:
$this->char++;
$char = $this->character($this->char);
if($char === '"') {
/* U+0022 QUOTATION MARK (")
Switch to the before attribute name state. */
$this->state = 'beforeAttributeName';
} elseif($char === '&') {
/* U+0026 AMPERSAND (&)
Switch to the entity in attribute value state. */
$this->entityInAttributeValueState('double');
} elseif($this->char === $this->EOF) {
/* EOF
Parse error. Emit the current tag token. Reconsume the character
in the data state. */
$this->emitToken($this->token);
$this->char--;
$this->state = 'data';
} else {
/* Anything else
Append the current input character to the current attribute's value.
Stay in the attribute value (double-quoted) state. */
$last = count($this->token['attr']) - 1;
$this->token['attr'][$last]['value'] .= $char;
$this->state = 'attributeValueDoubleQuoted';
}
}
private function attributeValueSingleQuotedState() {
// Consume the next input character:
$this->char++;
$char = $this->character($this->char);
if($char === '\'') {
/* U+0022 QUOTATION MARK (')
Switch to the before attribute name state. */
$this->state = 'beforeAttributeName';
} elseif($char === '&') {
/* U+0026 AMPERSAND (&)
Switch to the entity in attribute value state. */
$this->entityInAttributeValueState('single');
} elseif($this->char === $this->EOF) {
/* EOF
Parse error. Emit the current tag token. Reconsume the character
in the data state. */
$this->emitToken($this->token);
$this->char--;
$this->state = 'data';
} else {
/* Anything else
Append the current input character to the current attribute's value.
Stay in the attribute value (single-quoted) state. */
$last = count($this->token['attr']) - 1;
$this->token['attr'][$last]['value'] .= $char;
$this->state = 'attributeValueSingleQuoted';
}
}
private function attributeValueUnquotedState() {
// Consume the next input character:
$this->char++;
$char = $this->character($this->char);
if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) {
/* U+0009 CHARACTER TABULATION
U+000A LINE FEED (LF)
U+000B LINE TABULATION
U+000C FORM FEED (FF)
U+0020 SPACE
Switch to the before attribute name state. */
$this->state = 'beforeAttributeName';
} elseif($char === '&') {
/* U+0026 AMPERSAND (&)
Switch to the entity in attribute value state. */
$this->entityInAttributeValueState();
} elseif($char === '>') {
/* U+003E GREATER-THAN SIGN (>)
Emit the current tag token. Switch to the data state. */
$this->emitToken($this->token);
$this->state = 'data';
} else {
/* Anything else
Append the current input character to the current attribute's value.
Stay in the attribute value (unquoted) state. */
$last = count($this->token['attr']) - 1;
$this->token['attr'][$last]['value'] .= $char;
$this->state = 'attributeValueUnquoted';
}
}
private function entityInAttributeValueState() {
// Attempt to consume an entity.
$entity = $this->entity();
// If nothing is returned, append a U+0026 AMPERSAND character to the
// current attribute's value. Otherwise, emit the character token that
// was returned.
$char = (!$entity)
? '&'
: $entity;
$last = count($this->token['attr']) - 1;
$this->token['attr'][$last]['value'] .= $char;
}
private function bogusCommentState() {
/* Consume every character up to the first U+003E GREATER-THAN SIGN
character (>) or the end of the file (EOF), whichever comes first. Emit
a comment token whose data is the concatenation of all the characters
starting from and including the character that caused the state machine
to switch into the bogus comment state, up to and including the last
consumed character before the U+003E character, if any, or up to the
end of the file otherwise. (If the comment was started by the end of
the file (EOF), the token is empty.) */
$data = $this->characters('^>', $this->char);
$this->emitToken(array(
'data' => $data,
'type' => self::COMMENT
));
$this->char += strlen($data);
/* Switch to the data state. */
$this->state = 'data';
/* If the end of the file was reached, reconsume the EOF character. */
if($this->char === $this->EOF) {
$this->char = $this->EOF - 1;
}
}
private function markupDeclarationOpenState() {
/* If the next two characters are both U+002D HYPHEN-MINUS (-)
characters, consume those two characters, create a comment token whose
data is the empty string, and switch to the comment state. */
if($this->character($this->char + 1, 2) === '--') {
$this->char += 2;
$this->state = 'comment';
$this->token = array(
'data' => null,
'type' => self::COMMENT
);
/* Otherwise if the next seven chacacters are a case-insensitive match
for the word "DOCTYPE", then consume those characters and switch to the
DOCTYPE state. */
} elseif(strtolower($this->character($this->char + 1, 7)) === 'doctype') {
$this->char += 7;
$this->state = 'doctype';
/* Otherwise, is is a parse error. Switch to the bogus comment state.
The next character that is consumed, if any, is the first character
that will be in the comment. */
} else {
$this->char++;
$this->state = 'bogusComment';
}
}
private function commentState() {
/* Consume the next input character: */
$this->char++;
$char = $this->char();
/* U+002D HYPHEN-MINUS (-) */
if($char === '-') {
/* Switch to the comment dash state */
$this->state = 'commentDash';
/* EOF */
} elseif($this->char === $this->EOF) {
/* Parse error. Emit the comment token. Reconsume the EOF character
in the data state. */
$this->emitToken($this->token);
$this->char--;
$this->state = 'data';
/* Anything else */
} else {
/* Append the input character to the comment token's data. Stay in
the comment state. */
$this->token['data'] .= $char;
}
}
private function commentDashState() {
/* Consume the next input character: */
$this->char++;
$char = $this->char();
/* U+002D HYPHEN-MINUS (-) */
if($char === '-') {
/* Switch to the comment end state */
$this->state = 'commentEnd';
/* EOF */
} elseif($this->char === $this->EOF) {
/* Parse error. Emit the comment token. Reconsume the EOF character
in the data state. */
$this->emitToken($this->token);
$this->char--;
$this->state = 'data';
/* Anything else */
} else {
/* Append a U+002D HYPHEN-MINUS (-) character and the input
character to the comment token's data. Switch to the comment state. */
$this->token['data'] .= '-'.$char;
$this->state = 'comment';
}
}
private function commentEndState() {
/* Consume the next input character: */
$this->char++;
$char = $this->char();
if($char === '>') {
$this->emitToken($this->token);
$this->state = 'data';
} elseif($char === '-') {
$this->token['data'] .= '-';
} elseif($this->char === $this->EOF) {
$this->emitToken($this->token);
$this->char--;
$this->state = 'data';
} else {
$this->token['data'] .= '--'.$char;
$this->state = 'comment';
}
}
private function doctypeState() {
/* Consume the next input character: */
$this->char++;
$char = $this->char();
if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) {
$this->state = 'beforeDoctypeName';
} else {
$this->char--;
$this->state = 'beforeDoctypeName';
}
}
private function beforeDoctypeNameState() {
/* Consume the next input character: */
$this->char++;
$char = $this->char();
if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) {
// Stay in the before DOCTYPE name state.
} elseif(preg_match('/^[a-z]$/', $char)) {
$this->token = array(
'name' => strtoupper($char),
'type' => self::DOCTYPE,
'error' => true
);
$this->state = 'doctypeName';
} elseif($char === '>') {
$this->emitToken(array(
'name' => null,
'type' => self::DOCTYPE,
'error' => true
));
$this->state = 'data';
} elseif($this->char === $this->EOF) {
$this->emitToken(array(
'name' => null,
'type' => self::DOCTYPE,
'error' => true
));
$this->char--;
$this->state = 'data';
} else {
$this->token = array(
'name' => $char,
'type' => self::DOCTYPE,
'error' => true
);
$this->state = 'doctypeName';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -