Page 1 of 1
Sending and receiving variables within a single script.
Posted: Tue Mar 21, 2006 11:25 am
by Citizen
Basically, I need to create a php script that does the following.
1. States a variable
2. Sends the variable to another domath.php script
3. Receives the result from the domath.php script
4. Prints the result
Is there any way to do this without requiring the user to click anything?
Posted: Tue Mar 21, 2006 11:33 am
by chadillac
maybe I'm missing something, but can't you just have a script post back to itself.... or use an include to grab the variables work with them then output them to the user?
Posted: Tue Mar 21, 2006 11:51 am
by pickle
There are potentially a couple ways you could do this:
- You could include() the domath.php script. Including a file essentially runs it. So, you could declare the variable, include domath.php and have the results stored in your script:
Code: Select all
//index.php
<?PHP
$a = 2;
$b = 6;
include('domath.php');
echo $result;
?>
//domath.php
<?PHP
$result = $a + $b;
?>
//output would be: 8
- The other option would be to call that php script via the command line and capture the output from the file. Passing variables that way gets a little trickier though.
Posted: Tue Mar 21, 2006 11:54 am
by Citizen
My problem is that I need to state a variable and echo the variable in order for my Flash file on the page to be able to load the variable. The problem comes in that I dont have anywhere to echo the variable as it will look quite crappy.
My plan was going to be to echo the variable on a seperate page.
Posted: Tue Mar 21, 2006 12:03 pm
by a94060
this will most probably be accomplished using AJAX