Hi i'm fairly new to PHP and have been going through Learning PHP, MySQL, Javascript and CSS by Robin Nixon 2nd edition and found the following problem in the following example that I could not figure out.
I would appreciate any help to fixing it. Thanks
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
/*
*
*/
$f = $c = "";
if (isset($_POST['f']))
{
$f = sanitizeString($_POST['f']);
}
if (isset($_POST['c']))
{
$c = sanitizeString($_POST['c']);
}
// degree symbol done by alt + 0176
if ($f != '')
{
$c = intval((5 / 9) * ($f - 32));
$out = "$f °f equals $c °c";
}
elseif($c != '')
{
$f = intval((9 / 5) * $c + 32);
$out = "$c °c equals $f °f";
}
else
{
$out = "";
}
echo <<<_END
<html>
<head>
<title>Temprature Converter</title>
</head>
<body>
<pre>
Enter either Fahrenheit or Celsius and click Convert
<b>$out</b>
<form method="post" action="convert.php">
Fahrenheit <input type="text" name="f" size="7" />
Celsius <input type="text" name="c" size="7" />
<input type="submit" value="Convert" />
</form>
</pre>
</body>
</html>
_END;
function sanitizeString($var)
{
$var = stripslashes($var);
$var = htmlentitites($var);
$var = strip_tags($var);
return $var;
}
?>
</body>
</html>
*****************************************************************************************************
This is what happens after running the converter
( ! ) Fatal error: Call to undefined function htmlentitites() in C:\wamp\www\Chapter10\Chapter11\convert.php on line 68 Call Stack # Time Memory Function Location 1 0.0004 260784 {main}( ) ..\convert.php:0 2 0.0004 261616 sanitizeString( ) ..\convert.php:22