I have two pages of php. one is page1.php and the other is page2.php.
In page1.php there is a function which dynamically creates a form of html and return the full form at the end of the function.
And I want to the function to return a 2nd variable with the form. and i get that variable on page2.php.
How can i do this???
How to get two values from a function in php???
Moderator: General Moderators
Re: How to get two values from a function in php???
Wait what? Are you trying to pass two variable to "page 2" or pass two variables to a function.... i think you have to explain a little better on what you want to get done. 
Re: How to get two values from a function in php???
You can return a single array containing two scalars on page 1.
Then store whatever values you need in a session, or pass it thru the query string to page 2.
Then store whatever values you need in a session, or pass it thru the query string to page 2.
Re: How to get two values from a function in php???
I want to get the variable and the form on page2.php but in separate variables.
the function is in page1.php and i am calling the function in page2.php.
the function is in page1.php and i am calling the function in page2.php.
Re: How to get two values from a function in php???
I think your using the wrong terminology...what u need to use is an array where it stores both variable in on variable...hes an example...
Now if you pass $variable to anther page via the POST method or storing in a session you can echo it out like this.
And you will get ---> Variable 1
Code: Select all
$variable[0] = "Variable 1";
$variable[1] = "Variable 2";
Code: Select all
echo $variable[0];