Are there any alternatives to shell_exec and proc_open in PHP?

前端 未结 4 568
眼角桃花
眼角桃花 2021-01-15 23:25

It seems like I can\'t use shell_exec or proc_open on my shared server.

The message I get when I try to use it is:

W

4条回答
  •  别那么骄傲
    2021-01-16 00:12

    I assume you want to use this for async processing, for instance sending eMails in a separate process (hence the error in email.php). If so, please check if cURL is enabled. You can trigger your scripts through an HTTP request without waiting for the response.

    Further reading:

    • Asynchronous/parallel HTTP requests using PHP multi_curl
    • How to use curl_multi() without blocking
    • How do I make an asynchronous GET request in PHP?

    If cURL is not available, try to use with non-blocking streams:

    • http://de.php.net/manual/en/function.stream-set-blocking.php
    • http://thethoughtlab.blogspot.com/2007/04/non-blocking-io-with-php-mio.html

    For added security, consider using a self-defined API key, so the eMail sending URL cannot be triggered without permission. Pass this in as a GET or POST. You could also validate if the request came from the same server.

提交回复
热议问题