Calling PHP from PHP

Calling PHP from PHP

am 12.04.2007 07:18:26 von Alf C Stockton

Please tell me how I call one PHP script from another?
On successful completion of script A I need to call script B without
including it as part of script A.

--
Regards,
Alf Stockton www.stockton.co.za

Be cheerful while you are alive.
-- Phathotep, 24th Century B.C.
My email disclaimer is available at www.stockton.co.za/disclaimer.html

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

Re: Calling PHP from PHP

am 12.04.2007 07:32:27 von Hartleigh Burton

--Apple-Mail-17-480252079
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

Not sure if i understand properly... you don't want to use the include
() function or you don't want to have the code of script B in script A?

If it is the later you can use include("path/to/scriptB.php"); or
require("path/to/scriptB.php");

you can also use include_once() and require_once() if you want to
make sure that script B is not used more than once.




If you don't want to use the include() or require() functions then I
am not really sure.

I guess (providing you havn't already output headers) you could use
header() to direct the browser... or if headers have already been
sent you could use javascript to do a redirect?!


On 12/04/2007, at 3:18 PM, Alf Stockton wrote:

> Please tell me how I call one PHP script from another?
> On successful completion of script A I need to call script B
> without including it as part of script A.
>
> --
> Regards,
> Alf Stockton www.stockton.co.za
>
> Be cheerful while you are alive.
> -- Phathotep, 24th Century B.C.
> My email disclaimer is available at www.stockton.co.za/disclaimer.html
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>





Regards,
Hartleigh.


--Apple-Mail-17-480252079--

Re: Calling PHP from PHP

am 12.04.2007 07:57:50 von sam rumaizan

--0-355107035-1176357470=:83423
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

1- I have 50 php pages.
2- I want to include all 50 php pages in my main page.

include("1.php"); ...... include("50.php");
My question is:

can I put all of the include php pages in one php page and save it as includepages.php then include this php page to my main page include("includepages.php"); instead of listing all of the 50 pages include("1.php"); ...... include("50.php"); in my main page.

Hartleigh Burton wrote:

Not sure if i understand properly... you don't want to use the include
() function or you don't want to have the code of script B in script A?

If it is the later you can use include("path/to/scriptB.php"); or
require("path/to/scriptB.php");

you can also use include_once() and require_once() if you want to
make sure that script B is not used more than once.




If you don't want to use the include() or require() functions then I
am not really sure.

I guess (providing you havn't already output headers) you could use
header() to direct the browser... or if headers have already been
sent you could use javascript to do a redirect?!


On 12/04/2007, at 3:18 PM, Alf Stockton wrote:

> Please tell me how I call one PHP script from another?
> On successful completion of script A I need to call script B
> without including it as part of script A.
>
> --
> Regards,
> Alf Stockton www.stockton.co.za
>
> Be cheerful while you are alive.
> -- Phathotep, 24th Century B.C.
> My email disclaimer is available at www.stockton.co.za/disclaimer.html
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>





Regards,
Hartleigh.








---------------------------------
Don't get soaked. Take a quick peak at the forecast
with theYahoo! Search weather shortcut.
--0-355107035-1176357470=:83423--

Re: Calling PHP from PHP

am 12.04.2007 08:03:09 von John Comerford

--------------000504040906070303010708
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Yes, what you have described should work fine......


sam rumaizan wrote:
> 1- I have 50 php pages.
> 2- I want to include all 50 php pages in my main page.
>
> include("1.php"); ...... include("50.php");
> My question is:
>
> can I put all of the include php pages in one php page and save it as includepages.php then include this php page to my main page include("includepages.php"); instead of listing all of the 50 pages include("1.php"); ...... include("50.php"); in my main page.
>
> Hartleigh Burton wrote:
>
> Not sure if i understand properly... you don't want to use the include
> () function or you don't want to have the code of script B in script A?
>
> If it is the later you can use include("path/to/scriptB.php"); or
> require("path/to/scriptB.php");
>
> you can also use include_once() and require_once() if you want to
> make sure that script B is not used more than once.
>
>
>
>
> If you don't want to use the include() or require() functions then I
> am not really sure.
>
> I guess (providing you havn't already output headers) you could use
> header() to direct the browser... or if headers have already been
> sent you could use javascript to do a redirect?!
>
>
> On 12/04/2007, at 3:18 PM, Alf Stockton wrote:
>
>
>> Please tell me how I call one PHP script from another?
>> On successful completion of script A I need to call script B
>> without including it as part of script A.
>>
>> --
>> Regards,
>> Alf Stockton www.stockton.co.za
>>
>> Be cheerful while you are alive.
>> -- Phathotep, 24th Century B.C.
>> My email disclaimer is available at www.stockton.co.za/disclaimer.html
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>
>
>
> Regards,
> Hartleigh.
>
>
>
>
>
>
>
>
> ---------------------------------
> Don't get soaked. Take a quick peak at the forecast
> with theYahoo! Search weather shortcut.
>


--

1^st Floor, 184 -186 Glenferrie Road, Malvern VIC 3144

PH: *(03) 9500 1466*
FX : *(03) 9500 1469*
Email: johnc@styleman.com.au
Web: www.styleman.com.au

The information in this e-mail is confidential and is intended solely
for the addressee. Any views or opinions presented are solely those of
the author and do not necessarily represent those of Option Systems Pty
Ltd. If you are not the intended recipient, please delete this message
and contact the sender.

--------------000504040906070303010708--

Re: Calling PHP from PHP

am 12.04.2007 08:30:12 von php

Sidenote:

You can also do:
$dir = "folder/of/include/files";
$files = opendir($dir);
while ($file = readdir($file)):
if (substr($file,-4) == '.php'):
include_once($dir.'/'.$file);
endif;
endwhile;

but I wouldn't recommend it. :P

Mike


John Comerford skrev:
> Yes, what you have described should work fine......
>
>
> sam rumaizan wrote:
>> 1- I have 50 php pages.
>> 2- I want to include all 50 php pages in my main page.
>> include("1.php"); ...... include("50.php");
>> My question is: can I put all of the include php pages in one
>> php page and save it as includepages.php then include this php page
>> to my main page include("includepages.php"); instead of listing all
>> of the 50 pages include("1.php"); ...... include("50.php"); in my
>> main page.
>> Hartleigh Burton wrote:
>>
>> Not sure if i understand properly... you don't want to use the
>> include () function or you don't want to have the code of script B in
>> script A?
>>
>> If it is the later you can use include("path/to/scriptB.php"); or
>> require("path/to/scriptB.php");
>>
>> you can also use include_once() and require_once() if you want to
>> make sure that script B is not used more than once.
>>
>>
>>
>>
>> If you don't want to use the include() or require() functions then I
>> am not really sure.
>>
>> I guess (providing you havn't already output headers) you could use
>> header() to direct the browser... or if headers have already been
>> sent you could use javascript to do a redirect?!
>>
>>
>> On 12/04/2007, at 3:18 PM, Alf Stockton wrote:
>>
>>
>>> Please tell me how I call one PHP script from another?
>>> On successful completion of script A I need to call script B without
>>> including it as part of script A.
>>>
>>> --
>>> Regards,
>>> Alf Stockton www.stockton.co.za
>>>
>>> Be cheerful while you are alive.
>>> -- Phathotep, 24th Century B.C.
>>> My email disclaimer is available at www.stockton.co.za/disclaimer.html
>>>
>>> --
>>> PHP Windows Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>>
>>
>>
>>
>> Regards,
>> Hartleigh.
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------
>> Don't get soaked. Take a quick peak at the forecast with theYahoo!
>> Search weather shortcut.
>>
>
>

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

Re: Calling PHP from PHP

am 12.04.2007 13:32:19 von Alf C Stockton

Mikael Grön wrote:
> Sidenote:
>
> You can also do:
> $dir = "folder/of/include/files";
> $files = opendir($dir);
> while ($file = readdir($file)):
> if (substr($file,-4) == '.php'):
> include_once($dir.'/'.$file);
> endif;
> endwhile;
>
> but I wouldn't recommend it. :P
>
No neither would I recommend that solution and anyway I don't in any way
want to do an include.
If I was going to include then I may as well have coded that script into
the "calling" script and duplicate the stuff all over my system.
Maybe too much of my C programming background is showing but I just want
to call another script, the same as one would in C by calling another
program.


--
Regards,
Alf Stockton www.stockton.co.za

Beware of a dark-haired man with a loud tie.
My email disclaimer is available at www.stockton.co.za/disclaimer.html

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

Re: Calling PHP from PHP

am 12.04.2007 16:41:28 von php

If you're not using an external program or script to run all your php
scripts, but want one script to execute another, then include or require
are the only methods that'll do the job.
Putting the include / require -part in the end of the first script is
exactly the same as running them both after each other.

Perhaps doing a header("Location: next-script.php"); will do what you
ask, but I don't know if that works without a browser!

Mike



Alf Stockton skrev:
> Mikael Grön wrote:
>> Sidenote:
>>
>> You can also do:
>> $dir = "folder/of/include/files";
>> $files = opendir($dir);
>> while ($file = readdir($file)):
>> if (substr($file,-4) == '.php'):
>> include_once($dir.'/'.$file);
>> endif;
>> endwhile;
>>
>> but I wouldn't recommend it. :P
>>
> No neither would I recommend that solution and anyway I don't in any
> way want to do an include.
> If I was going to include then I may as well have coded that script
> into the "calling" script and duplicate the stuff all over my system.
> Maybe too much of my C programming background is showing but I just
> want to call another script, the same as one would in C by calling
> another program.
>

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

Re: Calling PHP from PHP

am 12.04.2007 18:04:32 von Jarrett Meyer

--0-694843659-1176393872=:30458
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

header("Location:next-script.php"); would work as long as nothing has been =
written to the screen. You can write to a DB, a cookie, a session, a file, =
etc, though to keep data flowing.=0A =0AThank you,=0AJarrett Meyer=0Ahttp:/=
/jarrettmeyer.blogspot.com No trees were harmed during this transmissi=
on; however, several electrons were terribly inconvenienced. ----- Ori=
ginal Message ----=0AFrom: Mikael Grön =0ATo: php-windows@l=
ists.php.net=0ASent: Thursday, April 12, 2007 10:41:28 AM=0ASubject: Re: [P=
HP-WIN] Calling PHP from PHP If you're not using an external program o=
r script to run all your php =0Ascripts, but want one script to execute ano=
ther, then include or require =0Aare the only methods that'll do the job.=
=0APutting the include / require -part in the end of the first script is =
=0Aexactly the same as running them both after each other. Perhaps doi=
ng a header("Location: next-script.php"); will do what you =0Aask, but I do=
n't know if that works without a browser! Mike Alf Stockton=
skrev:=0A> Mikael Grön wrote:=0A>> Sidenote:=0A>>=0A>> You can also do:=
=0A>> $dir =3D "folder/of/include/files";=0A>> $files =3D opendir($dir);=0A=
>> while ($file =3D readdir($file)):=0A>> if (substr($file,-4) == '.=
php'):=0A>> include_once($dir.'/'.$file);=0A>> endif;=0A>> endwhil=
e;=0A>>=0A>> but I wouldn't recommend it. :P=0A>>=0A> No neither would I re=
commend that solution and anyway I don't in any =0A> way want to do an incl=
ude.=0A> If I was going to include then I may as well have coded that scrip=
t =0A> into the "calling" script and duplicate the stuff all over my system=
..=0A> Maybe too much of my C programming background is showing but I just =
=0A> want to call another script, the same as one would in C by calling =0A=
> another program.=0A> -- =0APHP Windows Mailing List (http://www.php.=
net/)=0ATo unsubscribe, visit: http://www.php.net/unsub.php =0A=
=0A
--0-694843659-1176393872=:30458--