警告:preg_match():未知的修饰符't'

Help me plese :

 function getTextBetweenTags($string, $tagname)
 {
    $pattern = "/<$tagname>(.*?)<\/$tagname>/";
    preg_match($pattern, $string, $matches);
    return $matches[1];
 }

I got :

Warning: preg_match(): Unknown modifier 't' 

Also, i have try:

    $pattern = "~<$tagname>(.*?)<\/$tagname>~";

In this case, I have :

Warning: preg_match(): Compilation failed: range out of order in character class at offset 146 in

Sure, I have try variants

$pattern = "/<".$tagname.">(.*?)<\/".$tagname.">/";

Any ideas ? )

You need to change places of parameters in your getTextBetweenTags call. 'abc' is the name of the tag, not the string to search into, right?

$html = "<html><body><abc>HELLO</abc></body></html>";

function getTextBetweenTags( $string, $tagname ) {
    preg_match( "/\<{$tagname}\>(.*)\<\/{$tagname}\>/", $string, $matches );
    return $matches[1];
}

var_dump( getTextBetweenTags( $html, 'abc' ) );