PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
denisw
Forum Newbie
Posts: 14 Joined: Mon Jul 24, 2006 11:21 pm
Post
by denisw » Thu Jun 14, 2007 11:10 pm
Hi All,
Is it viable to run a particular php script (e.g : a.php) from inside other php script (e.g : b.php) ?
pls advise.
Thanks.
denisw
Forum Newbie
Posts: 14 Joined: Mon Jul 24, 2006 11:21 pm
Post
by denisw » Thu Jun 14, 2007 11:50 pm
Hi Jcart,
thanks for your reply.
However, in my case I would need more control in executing the other script.
I will elaborate with simple pseudo code as follows :
if (condition a) run foo.php;
elseif (condition b) run bar.php;
thanks.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Thu Jun 14, 2007 11:57 pm
Whats your question? You can control the flow of your program using if() and else() and include() to appropriate file
denisw
Forum Newbie
Posts: 14 Joined: Mon Jul 24, 2006 11:21 pm
Post
by denisw » Fri Jun 15, 2007 12:54 am
Oops, I thought that include() & require() can only be specified at the beginning of the script...
Ok, so the following codes shoud work for my case. Please advise :
if (condition a) include("a.php");
elseif (condition b) include("b.php");
thanks.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Fri Jun 15, 2007 1:26 am
Have you tried it?
denisw
Forum Newbie
Posts: 14 Joined: Mon Jul 24, 2006 11:21 pm
Post
by denisw » Mon Jun 18, 2007 4:02 am
Yes, I have tried and it works !
thanks.