Trouble Ticket Express does not support PHP in templates. You can try using PHP modules from CPAN
http://search.cpan.org/~gschloss/PHP-Interpreter-1.0.1/lib/PHP/Interpreter.pmhttp://search.cpan.org/~karasik/PHP-0.10/PHP.pmor parsing output of ttx.cgi via CLI, however you may have to rebuild complete CGI context in order to use some built-in features of PHP. As I understand session support assumes CGI (rather than command line) environment.
You may also try wrapping ttx.cgi ino PHP code using Perl package:
http://pecl.php.net/package/perl