Re: Including remote PHP script, Return DO NOT works.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quote from the manual:

"Handling Returns: It is possible to execute a return() statement inside an
included file in order to terminate processing in that file and return to
the script which called it. Also, it's possible to return values from
included files. You can take the value of the include call as you would a
normal function. This is not, however, possible when including remote files
unless the output of the remote file has valid PHP start and end tags (as
with any local file). You can declare the needed variables within those tags
and they will be introduced at whichever point the file was included. "

Therefore, it works as intended, and is not a fault of any kind.. The reason
it doesn't work for the OP is that the script tries to include the generated
output from the script on http://localhost/, which doesn't have any return
keywords, and thats why.. If he rename the file he tries to include to .txt,
it will work as he want it to..

http://php.net/manual/en/function.include.php - Example 11-7, and the text
right above it..
-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"B.A.T. Svensson" <B.A.T.Svensson@xxxxxxx> skrev i meddelandet
news:D291F33C586C8E48B95C26F8C805513A01A3DA17@xxxxxxxxxxxxxxxx
> I don't claim a script can't return a value. All I say is
> that the key word "return" is meant to be used with functions,
> not with scripts. In other words using "return" in a script,
> like the previous suggestion, is a semantic mistake/fault,
> and wont work as intended - in my naive oppinion, the
> interpreter should return an error message if a return
> is encountered outside a function.
>
> It's all about sematics of usage.
>
> -----Original Message-----
> From: DvDmanDT
> To: php-windows@xxxxxxxxxxxxx
> Sent: 2004-04-10 15:41
> Subject: Re:  Including remote PHP script, Return DO NOT works.
>
> Accutually, you _can_ return from included files, see manual for more
> info on that..
>
> Why it doesn't work, is because the script will include the generated
> HTML from simples.php, which is probably nothing.. Meaning there will be
no
> return statement,, And when there's no return in the file, include()
> will return the status of the include (true or false, 1 or 0).. To make
that
> work, try to rename simples.php to simples.txt and include it.. Cause then
> it wont be parsed by the server before PHP gets it.. Hope it makes sense..
>
> For both of you, look at this page:
> http://php/manual/en/function.include.php#AEN5536
> -- 
> // DvDmanDT
> MSN: dvdmandt$hotmail.com
> Mail: dvdmandt$telia.com
> "B.A.T. Svensson" <B.A.T.Svensson@xxxxxxx> skrev i meddelandet
> news:D291F33C586C8E48B95C26F8C805513A01A3DA16@xxxxxxxxxxxxxxxx
> > You should have a closer look at the concept of a function.
> >
> > A function are suposed to return a value (with "return"),
> > not a script.
> >
> > Try this in your main script:
> >
> > $fu = bar();
> > echo "$fu<br>\n";
> >
> > --[in your include file you need to have something likje this:]----
> >
> > function bar()
> >   $val = "simples";
> >   return $val;
> > }
> >
> > ------------------------------------------------
> >
> >
> >
> >
> > -----Original Message-----
> > From: ricardo.junior@xxxxxxxxxxxxxxxxxx
> > To: php-windows@xxxxxxxxxxxxx
> > Sent: 2004-04-10 03:55
> > Subject:  Including remote PHP script, Return DO NOT works.
> >
> > Hi All,
> >
> > I don't know if this is the wanted situation...
> > If you include a full URL path to a file in your own server (or
> specify
> > a remote php script) that has a RETURN statment, the value is not
> return
> > from this script (remotely or locally with full URL path).
> >
> > See example below:
> >
> > simples.php 's code:
> > <?
> >   $val = "simples";
> >   return $val;
> > ?>
> > -----------------------------------------------
> > main_1.php 's code:
> > <?
> >    $resultado = include ("./simples.php");
> >    print_r($resultado);
> > ?>
> > -----------------------------------------------
> > main_2.php 's code:
> > <?
> >    $resultado = include ("http://localhost/simples.php";);
> >    print_r($resultado);
> > ?>
> > -----------------------------------------------
> >
> > Running main_1.php (http://localhost/main_1.php) I got the following
> > output:
> >
> >    simples
> >
> > Running main_2.php (http://localhost/main_2.php) I got the following
> > output instead of "simples" as before:
> >
> >    1
> >
> > This is a normal situation?
> > If yes (or also if this is a bug), what could be done to return the
> > result of a remote script execution? There is another way to get the
> result
> > of a external execution?
> >
> > I need this to external users be able to run SQL commands on my mysql
> > server without pass them my server password. I pretend to use a
> > username/password protection to do some users just access some
> tables...
> > There is something like that I can use?
> >
> > Tahnks a lot,
> > Ricardo Jr.
> >
> > -- 
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux