Hello.
I've recently started learning PHP, and this has been irking me since:
<?php
$myTextbox = $_POST['myTextbox'];
if(isset($myTextbox)&&!empty($myTextbox)){
echo 'You Typed: '.$myTextbox;
}
?>
<html>
<head>
<title>My 39 Site!</title>
</head>
<body>
<form name = 'myForm' action = 'my39file.php' method = 'post'>
<input type = 'text' name = 'myTextbox' value = '<?php echo $myTextbox; ?>'/>
<input type = 'submit' name = 'submit'/></br></br>
</form>
</body>
</html>
It's a simple code I wrote. It has no errors, and it works just fine. The problem is that I don't understand WHY it works. I've been told numerously that the compiler reads code from top the bottom, but I'm failing to see how the rule applies in this case.
For instance, at the beginning of the code, I declared the variable $myTextbox and set it equal to the value of the textbox I created in HTML below. This boggles me. The textbox is created AFTER I declare the variable, so how does the computer know what form element I'm talking about?
I'm probably just omitting something. Could anybody enlighten me?
Thanks.