Well, I need to create a variable that will be updated inside one of my functions. Say I had.. index.php <?php include 'functions.php'; $var1 = "Hello"; test(); echo $var1; ?> Code (markup): Functions.php <?php function test() { $var1 = "Bye"; } ?> Code (markup): But it doesn't update my variable Suggestions? Thanks
Go find out about scope. If you want a quick fix: function test() { global $var1; $var1 = "Bye"; } PHP:
you can also pass the variable by reference to the function: function test(&$var1) { $var = "Bye!"; } PHP: if you run the function like this: $var = "Hi"; test($var); echo $var; // will output "Bye!" PHP:
Yeah I would also recomend passing by reference to functions when you need that value modified and returned. It's a memory saver too.
Then you should send the files containing your code onto a USB drive or a CD and then burn it. Smash whatever remains using a hammer, preferably a large one.
oh, before i forget: always pass a variable to the function, not just a string or array. For instance this won't work: test ( array('a', 'b', 'c') ); PHP: php will throw an error, as it can't update the value of the variable (because there is no value )