404 is for any resource not found. If a link points to one, it is the task of the server where the resource does not exist to give you this message. Quoting the RFC for HTTP Status Codes:
10.4.5 404 Not Found
The server has not found anything
matching the Request-URI. No
indication is given of whether the
condition is temporary or permanent.
The 410 (Gone) status code SHOULD be
used if the server knows, through some
internally configurable mechanism,
that an old resource is permanently
unavailable and has no forwarding
address. This status code is commonly
used when the server does not wish to
reveal exactly why the request has
been refused, or when no other
response is applicable.
In addition, clicking a link in the browser takes place long after PHP is done with the Page. PHP is server side, while user interaction happens completely isolated from this on the user's computer. So, there is no way to capture the click with PHP.
If you would want to capture clicks (technically it isn't), you'd have to route all external links to your own webserver that could prefetch the link via get_headers() to see if the resource exists. If not, you could present your own custom page to the user. But keep in mind that this is actually doing two HTTP requests then. First from user to your server, then from your server to the external page and your external links would probably look like this:
http://www.yourserver.com/external.php?url=example.com/someuri