Parameter/variable in URL not visible in php files

very shortly code in try_var.php:

<?php print("try URL variable myvar: $myvar
"); ?>

and I type the URL http://scuole.000webhostapp.com/try_var.php?myvar=5

The variable doesn’t arrive in the php file.

thanks

Add this before print line

$myvar = $_GET['myvar'];
1 Like

perfect, thank you!
Is this a php version issue (my code was working with my previous provider)?

Nope, you just have to get the variable from the url in order to use it :slight_smile:

here it works without GET

http://luganohotel.com/try_var.php?myvar=6

<?php
//$myvar = $_GET['myvar'];
print("<html><head></head><body>try URL variable myvar: $myvar<br>");

?>

Where is your website hosted?

in france, online.net

Hi @rivfed!

luganohotel.com is not hosted by us. If you need assistance for it please contact your hosting provider.

here it works without GET
http://luganohotel.com/try_var.php?myvar=63

It works for that website probably because you have register_globals directive set to ON. This indicates PHP version 5.3, but it depends on your host configuration.

We can’t know for sure because that site is not hosted by us.

1 Like

interesting, many thanks

You’re welcome :blush: