•  0
    PHP

    Escape special character in xml using PHP

      Asmin Jismun    251        0        Report content

    preg_replace('/[x00-x1f]/','',htmlspecialchars($string));
    


    if want to use strtoupper, use it before using htmlspecialchars otherwise it will not works

    preg_replace('/[x00-x1f]/','',htmlspecialchars(strtoupper($string)));
    


    for example,

     '&' => '$amp;'
    


    if use strtoupper after htmlspecialchars ‘$amp;’ will become ‘$AMP;’ and this will be interpreted wrong in xml

     

     


  •  


Leave a Comment

Please Login to insert comment.

 

Facebook Conversations