Place htmlspecialchars in PHP script

Hello,

I just placed my scripts on another server (infinityfree), but these do not display special characters.

I saw that we use the function :

function htmlspecialchars(
     $string,
     $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
     $encoding = ,
     $double_encode =
):

But where should I place it? Only in index.php or in all scripts? And where exactly?

Thanks

2 answers

  1. Hello,

    It would be preferable to continue the previous discussion, because the context and history are important.

    Regarding htmlspecialchars, its role is to clean/secure text before storing it in a database; this function will not resolve accent issues following a hosting provider migration.

    So, to better understand, it would be useful to know whether the problem affects the text present in the database, or if it concerns all the text on the page.
    0
    1. Hello,

      Look at the examples:

      You will need this for everything displayed from content entered by a user (you want to control what is shown and avoid injections)

      (Feldrip's answer is also valid)


      0