Print values of the same variable via GET PHP

0

I need to print on the screen the values of the same variable via $_GET , as shown in the example below.

http://localhost/sistema/cadastro_usuario.php?cod_igreja=4355&nome_user=Renan&[email protected]&celular=67992341353&cod_depto=20&cod_depto=10&cod_depto=35

Can anyone help me?

    
asked by anonymous 06.01.2017 / 19:28

3 answers

1

If I understood correctly you could do the following:

foreach($_GET as $key => $val) {
    echo $key. ': ' .$val;
}

In which $key will be for example cod_igreja and $val will be 4355 in the example you gave

To print only the value of one, in this case cod_igreja :

echo $_GET['cod_igreja'];
    
06.01.2017 / 19:29
1

Variable cod_depto is repeated. Then only the last will be displayed. In case, you need to turn it into an array to pass via get, putting the [] :

http://localhost/sistema/cadastro_usuario.php?cod_igreja=4355&nome_user=Renan&[email protected]&celular=67992341353&cod_depto[]=20&cod_depto[]=10&cod_depto[]=35

//Então, na hora de imprimir os valores de cod_depto, você faz:

$cod_deptos = $_GET['cod_depto'];
foreach($cod_deptos as $cod_depto){
    echo $cod_depto . "<br />";
}
    
06.01.2017 / 19:47
0

If your intent is to debug your code, you should actually seek to configure XDebug's use of your text editor of choice, rather than debugging at the bottom of the print.

  • PHPStorm - I think it comes along
  • Visual Studio Code - Install the plugin
  • Sublime Text - Install the plugin. Sublime integration is kind of weird though.

For debugging the Lusitanian base has var_dump() and print_r() .

    
06.01.2017 / 20:09