I would like to pass a parameter to a function. However, inside this parameter, I use variables that are defined inside the function. For example:
<?php
function foo($var){
$test = "test";
echo $var;
}
foo($test);
?>
In this example, I would like for the function to print out "test". Of course, this returns an error. However, this is what I am trying to do.
$testglobal, which defeats the purpose of defining it inside the function). Variables defined inside function should stay local, not accessible to the outside, to keep the code decoupled.$postas argument? Or do you mean the parameter name is$post?$postwill be populated with each element in$arrayduring the loop. I still don't understand and I'm even more confused.