Helper/Bibtex.php
function _escape_tex($tex)
    {
        $tex = str_replace("\\", "\\\\", $tex);
        $tex = str_replace('#', '\#', $tex);
        $tex = str_replace('$', '\$', $tex);
        $tex = str_replace('%', '\%', $tex);
        $tex = str_replace('^', '\^', $tex);
        $tex = str_replace('&', '\&', $tex);
        $tex = str_replace('_', '\_', $tex);
        $tex = str_replace('{', '\{', $tex);
        $tex = str_replace('}', '\}', $tex);
        return ($tex);
    }
function _escape_tex($tex)
    {
        $tex = str_replace("\\", "\\\\", $tex);
        $tex = str_replace('#', '\#', $tex);
        $tex = str_replace('$', '\$', $tex);
        $tex = str_replace('%', '\%', $tex);
        $tex = str_replace('^', '\^', $tex);
        $tex = str_replace('&', '\&', $tex);
        $tex = str_replace('_', '\_', $tex);
        $tex = str_replace('{', '\{', $tex);
        $tex = str_replace('}', '\}', $tex);
        return ($tex);
    }
function _escape_tex ( $ tex ) { $ tex = str_replace ( "\\" , "\\\\" , $ tex ) ; $ tex = str_replace ( '#' , '\#' , $ tex ) ; $ tex = str_replace ( '$' , '\$' , $ tex ) ; $ tex = str_replace ( '%' , '\%' , $ tex ) ; $ tex = str_replace ( '^' , '\^' , $ tex ) ; $ tex = str_replace ( '&' , '\&' , $ tex ) ; $ tex = str_replace ( '_' , '\_' , $ tex ) ; $ tex = str_replace ( '{' , '\{' , $ tex ) ; $ tex = str_replace ( '}' , '\}' , $ tex ) ; return ( $ tex ) ; }
Returns a string with special TeX characters escaped.

This method is to be used with any method which is exporting TeX, such
as the bibTex method. A series of string replace operations are
performed on the input string, and the escaped string is returned.

This code is taken from the Text_Wiki Pear package.

@author Jeremy Cowgar <jeremy@cowgar.com>

@access private
@param string $txt the TeX string
@return string the escaped TeX string
Returns a string with special TeX characters escaped .