Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created August 20, 2018 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/9b7330fffd24dd61aa1519004a2608b1 to your computer and use it in GitHub Desktop.
Save westonruter/9b7330fffd24dd61aa1519004a2608b1 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Simulate 500 Internal Server Error
* Description: Prints out a typically-looking PHP error when display_errors is enabled. To use, simply add <code>?internal_server_error</code> to any URL.
* Author: Weston Ruter
* Plugin URI: https://gist.github.com/westonruter/9b7330fffd24dd61aa1519004a2608b1
* Version: 1.0
* License: GPLv2 or later
*
* @package Simulate500Error
*/
add_action( 'init', function() {
if ( ! isset( $_GET['internal_server_error'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
return;
}
header( 'X-Robots-Tag: noindex' );
status_header( 500 );
printf( "<br />\n<b>Example error</b>: nothing bad happened, but this prints an error for testing purposes in <b>%s</b> on line <b>%d</b><br />\n", __FILE__, __LINE__ );
exit;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment