To escape characters with special meaning, like: .-[]() and so on, use \Q and \E.
For example:
<?php echo ( preg_match('/^'.( $myvar = 'te.t' ).'$/i', 'test') ? 'match' : 'nomatch' ); ?>
Will result in: match
But:
<?php echo ( preg_match('/^\Q'.( $myvar = 'te.t' ).'\E$/i', 'test') ? 'match' : 'nomatch' ); ?>
Will result in: nomatch