I'm just confused, I want to create that function that accepts 5 arguments but if I put something between brackets it gives me an error of undefined variables but the same code runs correctly with nothing between brackets. Below is the layout of my code:
Admin
Registered: 18 years ago
Posts: 10,001
Rating: 353
undefined variable is a notice, not an error, which you can turn off (wrong way), or define it before you use it (correct route) by using isset
Language: PHP
// this will generate the error notice$movie=$_POST[';movie';];echo"$movie";//or use $movie// this is the correct way if(isset($_POST[';movie';])){$movie=$_POST[';movie';];}echo"$movie";//or use $movie
(FYI...this is a new question and should actually be a new thread)
I think the first time your loop runs you are calling a function display but it has not been created yet...
move the display function out of the loop and out of the if statement...
it wont get executed until you call it...
so try this.
Language: PHP
function display($yourmovie){echo"Movie : ".$yourmovie;}if(isset($_REQUEST[';movie';])){foreach($_REQUEST[';movie';]as$yourmovie){
display($yourmovie);}}
Admin
Registered: 18 years ago
Posts: 10,001
Rating: 353
Good answer. A function is a "standalone", defined elsewhere. Having the function inside a loop is like defining it over and over. That said, you can just as well use the echo line on its own.