Halloween Sale 15% off Ends in See the plans
PHP

PHP Info Screen for Administrators

Adds a Tools > PHP Info screen showing the full phpinfo() report (extensions, limits, configuration), handy when a host's control panel does not show it.

Don’t have WPIDE yet? Install it on your site

Code

add_action( 'admin_menu', function () {
    add_management_page( 'PHP Info', 'PHP Info', 'manage_options', 'wpide-phpinfo', function () {
        if ( ! current_user_can( 'manage_options' ) ) {
            return;
        }

        ob_start();
        phpinfo(); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
        $info = (string) ob_get_clean();

        // Keep only the body and scope the table styles to this screen.
        if ( preg_match( '#<body[^>]*>(.*)</body>#is', $info, $match ) ) {
            $info = $match[1];
        }

        echo '<div class="wrap"><h1>PHP Info</h1><style>#wpide-phpinfo table{border-collapse:collapse;width:100%;margin-bottom:1em;background:#fff;}#wpide-phpinfo td,#wpide-phpinfo th{border:1px solid #dcdcde;padding:4px 8px;font-size:12px;vertical-align:top;word-break:break-word;}#wpide-phpinfo .e{background:#f6f7f7;font-weight:600;width:30%;}#wpide-phpinfo h2{margin-top:1.5em;}</style><div id="wpide-phpinfo">';
        echo wp_kses_post( $info );
        echo '</div></div>';
    } );
} );

Notes

The report reveals server details; it is limited to administrators. Remove the snippet when you no longer need it.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.