I'm just wondering if there is a way to set unwanted parameters other than 'null' within htmlentities(). So if I only want to disable double_encode, I am doing this:

Example:

$data = htmlentities(file_get_contents($file),null,null,0);

Just wondering of there is a different parameter setup (not that the above is problematic, as it does work). More of a curiosity thing than anything else.

P.S For those who are going to blindly suggest empty commas or zeros, the short answer is that won't do it.

    The default value for the second argument is ENT_COMPAT; the default for the third ("presently", according to the manual) is "ISO-8859-1".

      Yeah, I know the defaults.. I'm just wondering if there is a short form (syntactically speaking - other than null or having to type in the default values) to get to the double_encode.

        No, I think throwaway values are it. Note that what the value is can depend on the function in question: if 0 is a legitimate value for an argument, the default has to be something other than 0 or null or equivalent; preg_replace's $limit parameter is an example.

        If it's a one-off thing then the throwaway values do the deed. If certain clusters of arguments are common, then a function that provides them would simplify effort.

        function forced_htmlentities($string)
        {
            return htmlentities($string,null,null,0); 
        }
        

          OK, thanks for the heads up. Was more curious than anything else. Yeah, the function idea certainly would simplify its use for sure.

            Write a Reply...