public function getBlock( $tag )
{
//below finds the start tag, then matches any character multiple times
// until it finds <!-- END $tag -->, store the result in $tor
preg_match ('#<!-- START '. $tag . ' -->(.+?)
<!-- END '. $tag . ' -->#si', $this->content, $tor);
//the # is the delimiter, with s meaning treat as a single line
// so . matches \r\n for example. and i means insensitive
$tor = str_replace ('<!-- START '. $tag . ' -->', "", $tor[0]);
$tor = str_replace ('<!-- END ' . $tag . ' -->', "", $tor);
//remove the line with start on then remove line with end on.
return $tor;
//return what was between the two lines.
}
我在函数中添加了一些注释,希望它们能更清楚