Reputation: 302
i have the following functions
function a ($var) {
somecode;
b($var);
}
function b ($var) {
c($var);
}
function c($var) {
}
then suppose that i call these functions in a script
a(1);
a(2);
in programming languages like java for example, the normal order of execution is a(1) is executed then b(1) then c(1) then a(2) then b(2) then c(2).it means that a(2) is not called until all functions called by a(1) finish execution which inturn call other functions. but in php it didnt follow like that.in php it may go like that: a(1) then b(1) then a(2) then c(1). how to make sure that a(2) is not called until a(1) and all the functions that a(1) may call finish executing ? by the way i am calling the functions in cakephp with autorender=false, is cakephp responsible for that ?
Upvotes: 0
Views: 131
Reputation: 1666
I don't think so..it runs in sequential order. I got little confused so I checked myself(to calm down my heartbeat):
<?php
function a ($var) {
echo 'a->'.$var.'<br>';
b($var);
}
function b ($var) {
echo 'b->'.$var.'<br>';
}
a(1);
a(2);
?>
Gives you:
a->1
b->1
a->2
b->2
phew!
Upvotes: 0
Reputation: 116200
PHP runs sequential, like the other examples you gave. There is no different order, and nothing special you need to do to make this work.
Upvotes: 1