I am testing out some PHP code from a book just to see how it works. This is it:
<?php
$f = $c = "";
if (isset($_POST['f'])) $f = sanitizeString($_POST['f']);
if (isset($_POST['c'])) $c = sanitizeString($_POST['c']);
if ($f != '')
{
$c = ((5/9) * ($f - 32));
$out = "$f equals $c c";
}
elseif ($c != '')
{
$f = ((5/9) * ($c - 32));
$out = "$c c equals $f f";
}
else $out = "";
echo <<<_END
<html><head<title>Temp Conv.</title>
</head><body><pre>
Enter fahrenheit or celsius and click convert
<b>$out</b>
<form method="post" action="formValidation.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 = sanitizeString($var);
$var = htmlentities($var);
$var = strip_tags($var);
return $var;
}
?>
When I try to run the program in a browser, I get this error message:
"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in C:\xampp\xampp\htdocs\Trinity_Booksellers\formValidation.php on line 34"
That sounds bad to me. I'm not sure what the issue on line 34 could be (Line 34 is the first method on the function, if that's the correct terminology. I'm not familiar with 'sanitizeString' as far as it's role in memory allocation. Any ideas?
The example can be found on page 264 in "Learning PHP, MySQL, & JavaScript" which I do not in any way recommend. I mention it only because it's likely someone on the forum has it and can check it out for themselves.