PHP: Calling a function and passing a value to a variable?
I need to add a statement to the end of this script that calls the checkgrade() function and passes to it the value from the grade form variable. I have the form etc already programmed out, and I have a rough idea how to do this but I'm a little confused if I am on the right path or not. Here is my code, and how I think the statement should be written, but I would like another opinion or two before I try and finalise it on the server:
<?php
function checkGrade($Grade) {
switch ($Grade) {
case "A":
echo "Your grade is excellent.";
break;
case "B":
echo "Your grade is good.";
break;
case "C":
echo "Your grade is fair.";
break;
case "D":
echo "You are barely passing.";
break;
case "F":
echo "You failed.";
break;
default:
echo "You did not enter a valid letter grade.";
}
?>
statement:
function checkGrade($_GET["Grade"]
I have an HTML form I am using that has the Get action from this php, with a single text input named Grade.
oops sorry missed a bracket on the end of the statement there.
The code validates according to W3C.
rb, I get an error in line 34 saying incorrect parsing.
I edited it to this:
function checkGrade($_GET["Grade"])// Call the function
$Grade = $_GET["Grade"];//pass the value from the form variable
echo "<p>$Grade</p>";
which then gave me an error in line 33.
Ok its now telling me it is expecting a ")" in line 30, everything else is right but I don't seem to be missing a bracket, what am I missing?