Multiple PHP file execution.
Moderator: General Moderators
Multiple PHP file execution.
Hi friends....
Am new to php.
I have one parent php file(index.php) and 5 child files [test1.php, test2.php.........test5.php, with some contents each(let say each file may print "Hello world1...Hello world5") ]. I want to run all these child files when i fetch index.php. After all at the end of the execution control should remains in the parent file.
Can any one please help me.....
ThankS in advance.
Am new to php.
I have one parent php file(index.php) and 5 child files [test1.php, test2.php.........test5.php, with some contents each(let say each file may print "Hello world1...Hello world5") ]. I want to run all these child files when i fetch index.php. After all at the end of the execution control should remains in the parent file.
Can any one please help me.....
ThankS in advance.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Multiple PHP file execution.
Code: Select all
include('test1.php');
include('test2.php');
include('test3.php');
include('test4.php');
include('test5.php');
Re: Multiple PHP file execution.
Thanks the above code works fine...
Now i want to pass some string along with the file...
Let say [ include('test1.php?id=abc') ]
but above code gives error....
Can anyone please update the correct syntax...
Now i want to pass some string along with the file...
Let say [ include('test1.php?id=abc') ]
but above code gives error....
Can anyone please update the correct syntax...
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Multiple PHP file execution.
You don't need to pass variables to the include
Variables defined in your index.php are already available to the include file.
Variables defined in your index.php are already available to the include file.
index.php
Code: Select all
$id = 1;
include('file1.php')
include('file2.php')
echo $id.'<br />';
file1.php
Code: Select all
echo $id.'<br />';
$id += 1;
file2.php
Code: Select all
echo $id.'<br />';
$id += 1;
Re: Multiple PHP file execution.
I have slight deviation in my requirement...
Each child file should execute independently.
I mean to say i should see septate request for each child execution execution. The original content of the the child files follows
setcookie("name1", Test1, time()+3600, "/","", 0) -> for child test1.php
setcookie("name2", Test2, time()+3600, "/","", 0) -> for child test2.php
setcookie("name3", Test3, time()+3600, "/","", 0) -> for child test3.php
setcookie("name4", Test4, time()+3600, "/","", 0) -> for child test4.php
setcookie("name5", Test5, time()+3600, "/","", 0) -> for child test5.php
So when i execute the index file five cookies should be set from 5 different file.
At the end of the final child execution control should come back to the parent file.
Each child file should execute independently.
I mean to say i should see septate request for each child execution execution. The original content of the the child files follows
setcookie("name1", Test1, time()+3600, "/","", 0) -> for child test1.php
setcookie("name2", Test2, time()+3600, "/","", 0) -> for child test2.php
setcookie("name3", Test3, time()+3600, "/","", 0) -> for child test3.php
setcookie("name4", Test4, time()+3600, "/","", 0) -> for child test4.php
setcookie("name5", Test5, time()+3600, "/","", 0) -> for child test5.php
So when i execute the index file five cookies should be set from 5 different file.
At the end of the final child execution control should come back to the parent file.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Multiple PHP file execution.
Can't be done: not as a completely separate request if you want the included file to interact with the browser (and setting cookies definitely qualifies as interaction with the browser).
But why do they need to be compeletely independent? What are you actually trying to do?
Your example doesn't need to be independent! It doesn't even need separate files, because your cookie setting could all be done from index.php
But why do they need to be compeletely independent? What are you actually trying to do?
Your example doesn't need to be independent! It doesn't even need separate files, because your cookie setting could all be done from index.php
Re: Multiple PHP file execution.
I have to prepare some cookie related test page using PHP.
My requirement is like, i need to set 100 cookie of size 2MB form 100 different pages.
But this 100 cookie should be set when i fetch the index page.
[Note:If i see the request using any protocol analyzer i should see 100 separate request. ]
Can anyone plz suggest how to tackle this.
Thanks in advance.
My requirement is like, i need to set 100 cookie of size 2MB form 100 different pages.
But this 100 cookie should be set when i fetch the index page.
[Note:If i see the request using any protocol analyzer i should see 100 separate request. ]
Can anyone plz suggest how to tackle this.
Thanks in advance.
Re: Multiple PHP file execution.
You can't - the usual cookies data size permitted by the browsers per single domain is only 4 Kbyte.yempee wrote:My requirement is like, i need to set 100 cookie of size 2MB form 100 different pages.
There are 10 types of people in this world, those who understand binary and those who don't