<?php
$lines = array(
// INCLUDE: No closing tag.
'INCLUDE' => '<esi:include src="http://example.com/1.html" alt="http://bak.example.com/2.html"/>',
'INLINE opening' => '<esi:inline name="URI" fetchable="{yes | no}">',
'INLINE closing' => '</esi:inline>',
'CHOOSE opening' => '<esi:choose>',
'CHOOSE closing' => '</esi:choose>',
'WHEN opening' => '<esi:when test="...">',
'WHEN closing' => '</esi:when>',
'OTHERWISE opening' => '<esi:otherwise>',
'OTHERWISE closing' => '</esi:otherwise>',
'TRY opening' => '<esi:try>',
'TRY closing' => '</esi:try>',
'ATTEMPT opening' => '<esi:attempt>',
'ATTEMPT closing' => '</esi:attempt>',
'EXCEPT opening' => '<esi:except>',
'EXCEPT closing' => '</esi:except>',
'COMMENT' => '<esi:comment text="the following animation will have a 24 hr TTL." />',
'REMOVE opening' => '<esi:remove>',
'REMOVE closing' => '</esi:remove>',
'VARS opening' => '<esi:vars>',
'VARS closing' => '</esi:vars>',
);
foreach ( $lines as $type => $line ) {
preg_match( '%^<\s*(/\s*)?((?:esi:)?[a-zA-Z0-9-]+)([^>]*)>?$%', $line, $matches );
$slash = trim( $matches[1] );
$elem = $matches[2];
$attrlist = $matches[3];
echo "$type:\n";
echo "Original: '$line'\n";
echo "Slash: '$slash'\n";
echo "Elem: '$elem'\n";
echo "Attr List: '$attrlist'\n";
echo "\n";
}
preferences:
24.59 ms | 405 KiB | 5 Q