Page 1 of 1
execute a .php script from other php script
Posted: Thu Jun 14, 2007 11:10 pm
by denisw
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.
Posted: Thu Jun 14, 2007 11:21 pm
by John Cartwright
of course it is
include(),
require()
Posted: Thu Jun 14, 2007 11:50 pm
by denisw
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.
Posted: Thu Jun 14, 2007 11:57 pm
by John Cartwright
Whats your question? You can control the flow of your program using if() and else() and include() to appropriate file
Posted: Fri Jun 15, 2007 12:54 am
by denisw
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.
Posted: Fri Jun 15, 2007 1:26 am
by Benjamin
Have you tried it?
Posted: Mon Jun 18, 2007 4:02 am
by denisw
Yes, I have tried and it works !
thanks.