I get the "Warning: Undefined variable: txt " when I try to use a Undefined, but how can I define it or more importend how can I check if it is defined?
Thanks for Help
Manuals are your friends.
read about 'isset()'
or you may use the variable in a function.but you dont declare the variable to use in a function. use global $string;
in a function
Globals have been classified as evil in vincent's little black book of Peh-Hah-Peh.
i agree, although sometimes they seem necessary. how do you get around them?
Dominique
Pawel, probably it just shows you runtime minor warnings, if you don't want them turn it off in php.ini
Dominique, I agree with vincent that globabls can make your life miserable 🙂 how do you go around? pass 'em as an arguments.
cheers, AlCapone
If you find yourself using a whole bunch of arguments to pass a bunch of global vars and such, it might be worth your while to use an object to pass the data in. That way you don't have to remember the (often arbitrary) order of arguments for your function.
Okey, thank you all, this solved my Problem. BTW what is the vincent's little black book? Is it downloadable somewhere?
Good idea, but it does mean that you introduce another problem: Objects exist just as happily with only half their properties set. That means that instead of checking wether you put all arguments in a function call, you end up checking wether you set all properties in the object.
I'm not sure which is easier to solve... 🙂