Can I "drop" a PHP request without an answer?

I'm not quite sure if this is possible from PHP or even the HTTP protocol in depth. Is it possible to get a PHP script to run when it is requested, but then the script disconnects the connection? No answer?

Hope my question makes sense.

(I am using Apache)

+4
source share
5 answers

If you donโ€™t want to send any data at all, use sleep in a loop. In the end, the end of the client will expire and close the connection.

+3
source

When you serve php through Apache, there will always be an HTTP response. Calling the exit will just stop php processing - don't stop Apache. The right thing in your case is probably to send an HTTP response code other than 200 (OK). For example, 404 or 500. Check the specifications to find the one that applies to your situation.

You are sending an http response from php using:

<?php header("HTTP/1.0 404 Not Found"); exit; 
+6
source

You can use exit() or die() in a script to stop the script from executing, will this do what you want?

+3
source

Why do you need this? Surely you should send some kind of HTTP error code?

+1
source

It depends on the software you use. Apache, for example, terminates any scripts as soon as the connection is closed.

+1
source

All Articles