Page 1 of 1

evaluate php script and pass php variable to aother php

Posted: Fri Oct 28, 2005 7:38 pm
by eugene2006
hello!

lets say php script is here http://abc.com/a.php
this a.php works with inner mysql database "localhost" etc.
after all it returns answer like

echo "<b>".$country."</b>";
which is lets say outputs html <b>UK</b>

when i go to http://abc.com/a.php
it is fine, it shows me what i want it shows value of $country = <b>UK</b>;

but the problem is how do i get this value of $country from another location
lets say URL is like http://xyz.com/b.php ?

include did not work i did something wrong there...

how to evaluate things in php and then pass to another php script?

.............

in javascript there is no problem, all you have to do is do like this
<script src="http://abc.com/a.php"> </script>
and in javascript working space would be <b>UK</b>, which ofcourse leads to an error, but it is not a point

Posted: Fri Oct 28, 2005 7:45 pm
by alex.barylski

Posted: Fri Oct 28, 2005 7:57 pm
by feyd
if the file is outside the current domain, you will (very very ver likely) not be able to get any of its internal variables.

Posted: Tue Dec 27, 2005 3:02 pm
by eugene2006
fopen ok?

Posted: Tue Dec 27, 2005 3:04 pm
by foobar
eugene2006 wrote:fopen ok?
Pardon?

Posted: Tue Dec 27, 2005 7:44 pm
by josh
If the script is on the same server and you just want the output value, make a function to return the value and just use it in both places...

if it is on another server just do it like this:

Code: Select all

$h= fopen('http://example.com/a.php', 'r');
$variable = fread($h);
fclose($h);
echo 'The country is: '.$variable;