Jump to content

BorysSokolov

Members
  • Posts

    78
  • Joined

  • Last visited

Everything posted by BorysSokolov

  1. Hello. I have a quick question (it's probably easy to solve): why isn't the below code working? <?php $myFile = "testFile.txt"; $fh = fopen($myFile, 'w+'); $theData = fread($fh, 5); fclose($fh); echo $theData; ?> All I get is a blank page. Nothing is displayed, and I'm not sure what to do.
  2. 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.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.