开发者

Getting the vars of an external php script

I have two vars running on an external site and I am calling the script from another url.

How can I get these vars from one external script in my other script?

Example: MyVars.php

<?
$One = "This is one";
$Two = "This is two";
?>

Script on another server: GetVars.php

<?
include 'http://www.MyS开发者_如何学编程ite.com/MyVars.php';

echo $One . $Two;
?>

The vars are not showing up on the second site. Is there a way I can access them?

Thanks -Ed


You can't include a remote script the way you're trying to, particularly as executable code. The remote .php script will almost certainly be (and should be) executed by the remote server, and only its output (i.e. the stuff it echos) will be returned to the requesting client (i.e. your code).

You should download whatever PHP script you need, upload it to your server, then include it locally.


This should work. Including files, basically "smashes" the PHP scripts into one large PHP that the server executes. Try including the file with a relative URL.

UPDATE: Sorry, didn't see the part about you need to pull it from an external site. Hmm... if you own that site, you would need to find someway to access it with a relative URL. For security reasons, you cannot include scripts from another site/server like you are doing.


The script is on another server? I would imagine that would cause problems. You wouldn't be able to include anything (if you could, serious security problems would arise). The two files must be on the same server.


According to the manual, you may be able to do this, but use Get to retrieve the values of $One and $Two

http://php.net/manual/en/function.include.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜