Is there a way I can perform one PHP function first and then execute another function after the first function?
views:
74answers:
4
A:
You could always nest the function calls, so that the last step in function 1 is executing function 2. This is assuming, of course, that the execution of Function 2 ALWAYS follows Function 1.
That is,
function1()
{
// do stuff;
function2();
}
Andrew
2010-08-06 02:13:30
Why that?... it is the same as executing them separately one after another... as `function(); someOtherFunction();`
Garis Suero
2010-08-06 02:20:58
Good question. It's simply a matter of, if this is always the case, it saves writing by 50%.
Andrew
2010-08-06 04:17:26
+4
A:
PHP executes code sequentially. If you have two function calls:
foo();
bar();
// more code
it will execute the lines in foo sequentially, return to the line after that call (bar();), and execute it, which will call bar and execute its lines sequentially. Then bar will return to the line after the bar(); call (// more code) and execution will continue there
Michael Mrozek
2010-08-06 02:15:15