php - How to wait for a variable to return before the next function starts -
I have a simple task 1 that makes an HTTP request for a Google API and returns $ results then I have If another function is 2, if the $ result isset, then some computing should use the $ result and then return the last final $. .
My problem is that the call to Google API takes a few seconds and as a result of the time received by Function 1 by Function 1, Function 2 has already paid $ last payment Have done
What I have to do, is to start function 1 completely and return the result of $ 2 before returning the result too.
Well I'm looking for a solution that is not just using "sleep" because this function will not guarantee that the $ result is actually back. (Unless there is a way for $ refunds or sleep (1))
Sample code for visual galls and boys
function1_geocode ($ addresses ); // This function makes an HTTP request for Google and returns the $ result function2_proximitysearch () {if (isset ($ result)) {// Essentially the script gets until that time, the $ result is not yet returned So no one is executing "some stuff" code // some stuff} other {// some other stuff}}
PHP is not asynchronous The function is executed one after the other.
Comments
Post a Comment