htmlentities() vs. htmlspecialchars()

前端 未结 12 2187
走了就别回头了
走了就别回头了 2020-11-22 02:50

What are the differences between htmlspecialchars() and htmlentities(). When should I use one or the other?

12条回答
  •  遇见更好的自我
    2020-11-22 03:02

    One small example, I needed to have 2 client names indexed in a function:

    [1] => Altisoxxce Soluxxons S.à r.l.
    [5] => Joxxson & Joxxson
    

    I originally $term = get_term_by('name', htmlentities($name), 'client'); which resulted in term names that only included the ampersand array item (&) but not the accented item. But when I changed the variable setting to htmlspecialchars both were able to run through the function. Hope this helps!

提交回复
热议问题