You are here: Re: Asynchronous function call? « PHP Programming Language « IT news, forums, messages
Re: Asynchronous function call?

Posted by petersprc on 08/12/07 19:25

The system could also run your command for you when you use the at
command.

For example, this page launch.php calls the at command, which loads
the web page batch.php in the background:

<?

// File: launch.php

function launch($url)
{
$cmd = 'echo lynx -source ' . escapeshellarg($url) .
' | at now 2>&1';
exec($cmd, $output, $exitCode);
if ($exitCode != 0) {
$msg = "Command \"$cmd\" failed with exit code $exitCode: ";
$msg .= join("\n", $output);
trigger_error($msg, E_USER_ERROR);
return false;
}
return true;
}

$done = false;
if (isset($_GET['btn'])) {
$url = 'http://my.tld/batch.php';
$done = launch($url);
}

?>

<h3>Launch</h3>

<? if ($done) { ?>
<p>Command launched in background.</p>
<? } ?>

<form action="launch.php">
<input type=submit name=btn value=" Go ">
</form>

On Aug 11, 12:47 pm, "Fabio" <znt.fa...@virgilio.it> wrote:
> Hi all
>
> There is a way to exec a function asynchronously?
> I need to exec a function that is too slow but for me can be executed in the
> background... there is no way???
>
> Thanks

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация