so that it serves the question mark before a variable

1

Good excuse a question I'm starting in php and a partner asked me to serve the question mark before a variable since he is using it in this part

< a href = "? load '=' create" & nt; Register < / a >

I say it's to pass variables by url but I'm not sure if that's what or what that part of the code does

    
asked by edmond696 05.02.2017 в 06:19
source

2 answers

0

That's right, that's what's called the "URL Query string".

At the beginning of the web page addresses contained the hierarchical structure of the site directories. For example:

www.sitiodejemplo.net/paginaprincipal/paginasecundaria/contenido.html

These sites were static: unless the administrator modifies the pages they would always show the same content to the visitors.

Later dynamic sites appeared. In this case, the server automatically creates the page when the browser requests it. For this it uses a series of parameters or data that are included in the URL. These are usually composed of a name and a value separated by the equal sign. An example of a dynamic address would be:

www.examplesite.net/page.php?valuename1=value1&valuename2=value2

The? "" is used to split the URL of the Query string. The Query string is basically a list of variables and their values.

To be more precise, in the URL that you are, it will go but with the parameters:

  • load, that its value is 'create'

< a href="?cargar'='crear">Registrar < /a>

leaving for example as a result www.example.com/page.php?load=create

    
answered by 06.02.2017 / 02:20
source
3

Yes, it is to pass variables from one page to another through the URL. Although in your specific case, it would be to pass variables to the same page you are on (because none is specified in the link).

Then in PHP you can read the variable through $_GET :

$miVar = $_GET["cargar"];

(ideally you should check that the parameter exists and that it is not empty, etc., but this is just an example)

    
answered by 05.02.2017 в 06:32