Jump to content

Variable content gets lost


pesto

Recommended Posts

part of my code:

 

-----------------------------------------

var_dump($adr);

echo "<BR>";

 

function print_form() {

global $error, $print_again, $page, $vorn, $name, $adr, $abs, $betr, $mess, $empf;

 

var_dump($adr);

echo "<BR>";

-----------------------------------------

 

The first var_dump($adr) prints out a value (21 for example).

The second var_dump($adr) has no more value, is prints out NULL.

 

Can someone please tell me why?

Link to comment
https://forums.phpfreaks.com/topic/173511-variable-content-gets-lost/
Share on other sites

It's generally a bad idea to use global variables better would be to pass the variables as parameter to function. About your problem I cant see you calling that function anywhere`: print_form(); ? You just define the function but never call it or is there more code to this?

 

<?php
// define a function
function sayHello()
{
    echo 'heello!';
}

// call the function
sayHello(); // actually prints out that heello!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.