ID: 14165 Updated by: [EMAIL PROTECTED] Reported By: steve at petabit dot com -Status: Bogus +Status: Open -Bug Type: Feature/Change Request +Bug Type: Documentation problem Operating System: Linux PHP Version: 4.0.5 New Comment:
If you use include('http://some_server/something.php'); something.php is executed on "some_server". It's impossible to return strings with "return" from there. But the output of http://some_server/something.php is included in your script and executed there. So just make _the output_ of something.php a valid php script which sets your variables - so you can use these variables in your local script. E.g.: <?php // something.php on the remote server echo '<?php $return_value = "a string"; ?>'; ?> On the local server: <?php include('http://some_server/something.php'); echo $return_value; ?> As the manual explicitly mentions that you can use a return statement to pass values from the included script, but does not mention that this doesn't work via HTTP or FTP, I'd say this is a Documentation problem. (I don't know what the manual said in 2001, maybe the return statement could not be used in included files back then.) Previous Comments: ------------------------------------------------------------------------ [2003-08-06 21:09:41] tim at pmedia dot be Allow me to rephrase Steve's problem described in #14165 again as I'm experiencing the same trouble. When including a remote php-file (a php-file on another server) in a script, that php-file is parsed (if server configured to) which basically means the script is runned. The problem we experience is that the parsed script's return value(s) defined at the end in a return() statement don't seem to arrive in the original script. Steve reports only 'integers'. I have seen only a '1', which is according the docs just the value returned if no return() statement is used. If the 2 scripts are located on the same server, the problem doesn't show up. ------------------------------------------------------------------------ [2001-11-21 17:32:22] steve at petabit dot com Okay, there's some simple sample code at bug 14164. Basic idea is that I have 2 machines, one public, one firewalled and non-routed. The public one should be able to access the database on the private one, but nobody else should. Thanks for the attention! Steve ------------------------------------------------------------------------ [2001-11-21 17:01:34] [EMAIL PROTECTED] Maybe if you added some example script here (which you think should work) we might understand what you mean? And note that include/require don't return anything. They are language constructs, not functions. --Jani ------------------------------------------------------------------------ [2001-11-21 16:35:14] steve at petabit dot com Dear Brian, Marco et al: Sorry to be persistent, but I am pretty sure that my postings have been misunderstood, and the last reply I just got from Marco confirms it. I'm hoping once you understand the question, the "bogus" nature of the question will go away. According to the php "include()" manual, and in my own experience, it is perfectly valid to request that a remote file be executed as php, using include() or require(). One need only compile using "URL fopen wrappers": (manual quotes in [[[ ]]]) [[[If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be include() ed using an URL instead of a local pathname. See Remote files and fopen() for more information. ]]] It is also possible to pass variables to the include()ed file: [[[ If the require() ed file is called via HTTP using the fopen wrappers, and if the target server interprets the target file as PHP code, variables may be passed to the require() ed file using an URL request string as used with HTTP GET. This is not strictly speaking the same thing as require() ing the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script. ]]] SO: The missing feature/doc is: How do I get the require()ed file to pass back some string information? I can't use the HTTP GET-style request string, or even the return() function within an include() (because it only returns an integer). I don't think this is a bogus request, it seems to me to be a logical extension of the URL request idea. If it's currently impossible, I'm looking for a workaround. Marco's suggestion to print out the database using cvs doesn't change anything, since I still can't pass a string back. Best regards, Steve Rapaport. ------------------------------------------------------------------------ [2001-11-21 15:55:06] [EMAIL PROTECTED] Hi, what are you means with remote? include("http://www.mysite.com/phpscript.php"); Dont work. the .php are parsed befor and you cant get source to your script. If you need content from a database so print's it as csv and use the output in your script. http://www.php.net/csv -- Marco Btw. Ask this type of question on the general or dev mailing list. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/14165 -- Edit this bug report at http://bugs.php.net/?id=14165&edit=1 -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php