Pon*_*ing 2 php arguments function exec background-process
我有一个文件,Notification.php这是一个类.它的结构是这样的:
Class Notificaiton
{
public function sendNotification($token,$count)
{
// Here is the code for sending push notification(APNS)
}
}
Run Code Online (Sandbox Code Playgroud)
通常,如果我想从另一个PHP文件中调用此函数,那么我必须创建一个类的对象,然后调用它的方法如下:
$notification = new Notification();
$notification->sendNotification($token,$value);
Run Code Online (Sandbox Code Playgroud)
但我想做的是在后台进程中调用它.所以我使用exec()如下命令:
exec("/usr/bin/php /path/to/Notification.php >> /path/to/log_file.log 2>&1 &");
Run Code Online (Sandbox Code Playgroud)
在这里,我不知道如何可以调用function(sendNotificaiton())的file(Notification.php),并传递参数的参数:$令牌和$算什么?
我发现exec/shell_exec/passthru commands可以帮助我.但在这种情况下,我用这三个命令中的哪个命令?
请指导我这个.任何帮助将不胜感激.
最好再创建一个php文件并调用其中的方法.喜欢
notificationCall.php:
<?php
include 'notification.php';
$token = $argv[1];
$count = $arg2[2];
$notification = new Notification();
$notification->sendNotification($token,$count);
?>
Run Code Online (Sandbox Code Playgroud)
exec("/ usr/bin/php /path/to/notificationCall.php令牌计数>> /path/to/log_file.log 2>&1&");