I'm using PHP 7.3.2 on my laptop that runs on Windows 10 Home Single Language 64-bit operating system.
I've installed the latest version of XAMPP installer on my laptop which has installed the Apache/2.4.38 (Win32) and PHP 7.3.2
Please do consider below prototype definition of the built-in PHP function htmlspecialchars()
from the PHP Manual:
htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = TRUE ]]] ) : string
Now, I only want to set the last optional parameter i.e. $double_encode
with a boolean value FALSE
and keep all other optional parameters set to their default values.
For achieving this I tried below code :
<?php
echo htmlspecialchars('&', '', '', FALSE);
?>
After executing the above code I got following output in my web browser :
Warning: htmlspecialchars() expects parameter 2 to be int, string given in th67i.php on line 2
I'm not understanding where I'm going wrong. I took care of other parameters to be set to their default values by keeping blank spaces separated by commas and only assigning the optional parameter $double_encode
to boolean value FALSE
.
Then why I'm not able to get the output and getting some warning? Why? What mistake I'm making in my code?