Can a 404 page contain php code?

Created a 404 error page. It was necessary to display a variable there, via echo. It doesn’t work.

Answer 1, authority 100%


header("Status: 404 Not Found");
echo "blahblahblah";


ErrorDocument 404 /404.php

Answer 2, authority 100%

Maybe. How did you create it, where did you register, which web server?

For Apache, write in the config like this, for example:

ErrorDocument 404 /my404.php

and go.

Answer 3

In the server settings, you need to specify the URL of the PHP script for the 404th page.

Answer 4

Create a php page and set it as the error page.
I was able to display the URL that was accessed.