Wrote the simplest code

<?php echo "Hello, $name"; ?> 

But when you type in url: test.ru/index.php?name=Vasilii , only Hello displayed on the page. I tried to test.ru/index.php?name=Vasilii variable from quotes, i.e. "Hello, ". $name "Hello, ". $name didn't help either. The same with forms, does not take away data. I use denwer.

  • one
  • And so I tried, read carefully. - PirateNinja
  • one
    By the way, I strongly recommend changing the textbook to the one published in this century. - Ipatiev
  • @ Ipatiev Thank you very much. - PirateNinja

2 answers 2

Data that comes from outside through GET requests (via the address bar) or POST is available through the $ _GET and $ _POST arrays, respectively.

However, before working with these arrays it is necessary to check the presence of data in them using the isset function. This will insure against many errors.

An example for your case:

 if (isset($_GET['name'])) { echo "Hello,".$_GET['name']; } 
  • Thanks, already figured it out. The 2003 textbook, I thought, may be something wrong with the interpreter. - PirateNinja

All parameters passed through the URL fall into the $_GET[] array. In your case, $name will be available through $_GET['name'] . Parameters passed through the form are included in $_POST if method=post is specified in the form, respectively.

The difference in types is the maximum amount of data that can be transferred. For the GET method, this is 255 characters (the limit is related to the maximum possible long URL)