On the face of it your code looks ok - although I probably would use
strncasecmp().
fyi ... dokuWiki uses "eval()" on each <php> block on your page. The results are captured by output buffering and added to the page content. The "eval()" is executed within a class method, refer to inc/parser/xhtml.php.
While the above doesn't provide a solution, hopefully it'll assist you in debugging your code.
An alternative, is to make your self a small plugin to do the same work. Syntax plugins really aren't that complex to deal with and do mean your php is executing in a more usual environment. Once you have made one or two you'll find that you can churn one out in about the same time it takes to write the meaningful code. One note, if you do attempt this route - for dynamically loaded content you need to make sure your plugin disables page caching.