1

Is there a way in PHP to call a function within a script and then continue through the rest of the script without waiting for that function to finish?

For example, if I have a script like this:

<?php

    ... some code ...

    getImage($value);

    ... some code ...

?>

getImage() is a function that takes, on average, 5 seconds to complete. Is there a way to call getImage() and continue through the rest of the script without having to wait for a response so that the user doesn't have to wait as long?

Thanks.

  • 2
    and what do you do with the result of the function? – Sebas Oct 21 '14 at 21:56
  • 4
    possible duplicate of [PHP threading call to a php function asynchronously](http://stackoverflow.com/questions/13846192/php-threading-call-to-a-php-function-asynchronously) – p.s.w.g Oct 21 '14 at 21:56
  • @Sebas - A function isn't obliged to return any result, and even if it does, it's not uncommon to ignore it. (When did you last do anything with the return value from the sort() function?) – Mark Baker Oct 21 '14 at 21:59
  • @Sebas Nothing. The function does its own thing. –  Oct 21 '14 at 22:00
  • @MarkBaker, really??! – Sebas Oct 21 '14 at 22:42

0 Answers0