3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySettingsPage { /** * Holds the values to be used in the fields callbacks */ private $options; /** * Start up */ public function __construct() { add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'page_init' ) ); } /** * Add options page */ public function add_plugin_page() { // This page will be under "Settings" add_options_page( 'Settings Admin', 'My Settings', 'manage_options', 'my-setting-admin', array( $this, 'create_admin_page' ) ); } /** * Options page callback */ public function create_admin_page() { // Set class property $this->options = get_option( 'my_option_name' ); ?> <div class="wrap"> <?php screen_icon(); ?> <h2>My Settings</h2> <form method="post" action="options.php"> <?php // This prints out all hidden setting fields settings_fields( 'my_option_group' ); do_settings_sections( 'my-setting-admin' ); submit_button(); ?> </form> </div> <?php } /** * Register and add settings */ public function page_init() { register_setting( 'my_option_group', // Option group 'my_option_name', // Option name array( $this, 'sanitize' ) // Sanitize ); add_settings_section( 'setting_section_id', // ID 'My Custom Settings', // Title array( $this, 'print_section_info' ), // Callback 'my-setting-admin' // Page ); add_settings_field( 'id_number', // ID 'ID Number', // Title array( $this, 'id_number_callback' ), // Callback 'my-setting-admin', // Page 'setting_section_id' // Section ); add_settings_field( 'title', 'Title', array( $this, 'title_callback' ), 'my-setting-admin', 'setting_section_id' ); } /** * Sanitize each setting field as needed * * @param array $input Contains all settings fields as array keys */ public function sanitize( $input ) { $new_input = array(); if( isset( $input['id_number'] ) ) $new_input['id_number'] = absint( $input['id_number'] ); if( isset( $input['title'] ) ) $new_input['title'] = sanitize_text_field( $input['title'] ); return $new_input; } /** * Print the Section text */ public function print_section_info() { print 'Enter your settings below:'; } /** * Get the settings option array and print one of its values */ public function id_number_callback() { printf( '<input type="text" id="id_number" name="my_option_name[id_number]" value="%s" />', isset( $this->options['id_number'] ) ? esc_attr( $this->options['id_number']) : '' ); } /** * Get the settings option array and print one of its values */ public function title_callback() { printf( '<input type="text" id="title" name="my_option_name[title]" value="%s" />', isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : '' ); } } if( is_admin() ) $my_settings_page = new MySettingsPage();

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0110.00416.63
8.3.50.0130.00721.87
8.3.40.0090.01218.87
8.3.30.0070.00719.01
8.3.20.0080.00020.34
8.3.10.0040.00423.33
8.3.00.0040.00419.38
8.2.180.0110.00716.63
8.2.170.0120.00322.96
8.2.160.0030.01020.50
8.2.150.0000.00824.18
8.2.140.0070.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00422.27
8.2.110.0060.00320.39
8.2.100.0120.00017.78
8.2.90.0100.00019.09
8.2.80.0000.00817.97
8.2.70.0060.00617.63
8.2.60.0030.00617.79
8.2.50.0000.00818.07
8.2.40.0040.00419.81
8.2.30.0040.00418.08
8.2.20.0030.00617.88
8.2.10.0000.00818.11
8.2.00.0050.00317.87
8.1.280.0040.01425.92
8.1.270.0030.00522.36
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00323.71
8.1.230.0080.00420.97
8.1.220.0030.00617.74
8.1.210.0030.00618.77
8.1.200.0030.00617.36
8.1.190.0080.00017.13
8.1.180.0060.00319.01
8.1.170.0000.00818.46
8.1.160.0030.00622.07
8.1.150.0000.00818.62
8.1.140.0090.00017.33
8.1.130.0030.00317.73
8.1.120.0020.00517.37
8.1.110.0030.00517.27
8.1.100.0040.00417.43
8.1.90.0050.00217.37
8.1.80.0040.00417.25
8.1.70.0050.00217.31
8.1.60.0100.00317.56
8.1.50.0030.00617.55
8.1.40.0030.00517.55
8.1.30.0030.00517.52
8.1.20.0000.00817.65
8.1.10.0040.00417.53
8.1.00.0000.00817.50
8.0.300.0060.00318.77
8.0.290.0050.00217.15
8.0.280.0000.00818.36
8.0.270.0030.00317.27
8.0.260.0040.00417.25
8.0.250.0070.00017.02
8.0.240.0050.00316.97
8.0.230.0070.00016.93
8.0.220.0030.00316.99
8.0.210.0000.00817.03
8.0.200.0000.00616.97
8.0.190.0000.00917.01
8.0.180.0070.00016.82
8.0.170.0000.00817.00
8.0.160.0070.00016.99
8.0.150.0040.00416.80
8.0.140.0020.00716.94
8.0.130.0000.00513.41
8.0.120.0030.00516.80
8.0.110.0080.00016.90
8.0.100.0000.00716.94
8.0.90.0070.00016.99
8.0.80.0150.00016.86
8.0.70.0030.00516.94
8.0.60.0040.00416.97
8.0.50.0070.00016.73
8.0.30.0120.00616.88
8.0.20.0120.00917.40
8.0.10.0040.00417.05
8.0.00.0180.00916.74
7.4.330.0000.00515.00
7.4.320.0000.00616.52
7.4.300.0000.00616.52
7.4.290.0080.00016.36
7.4.280.0030.00516.53
7.4.270.0070.00016.42
7.4.260.0070.00016.49
7.4.250.0000.00916.55
7.4.240.0020.00516.50
7.4.230.0050.00216.68
7.4.220.0040.01416.45
7.4.210.0100.00516.64
7.4.200.0000.00716.63
7.4.190.0040.00416.64
7.4.160.0130.00316.62
7.4.150.0130.00317.40
7.4.140.0090.00817.86
7.4.130.0050.01116.60
7.4.120.0080.00916.53
7.4.110.0030.01316.32
7.4.100.0090.01016.62
7.4.90.0080.00816.54
7.4.80.0140.00319.39
7.4.70.0040.01416.49
7.4.60.0080.00816.69
7.4.50.0040.00416.30
7.4.40.0060.00916.36
7.4.30.0100.00716.45
7.4.00.0130.00314.96
7.3.330.0040.00213.30
7.3.320.0030.00313.30
7.3.310.0050.00316.19
7.3.300.0040.00416.44
7.3.290.0100.00316.39
7.3.280.0100.00516.40
7.3.270.0070.01017.40
7.3.260.0150.00316.34
7.3.250.0110.00616.50
7.3.240.0030.01416.35
7.3.230.0080.01216.64
7.3.210.0070.01016.49
7.3.200.0120.00619.39
7.3.190.0100.01316.33
7.3.180.0100.00716.53
7.3.170.0090.00616.52
7.3.160.0090.00616.44
7.3.120.0030.01315.08
7.2.330.0030.01416.55
7.2.320.0150.00816.60
7.2.310.0070.01016.69
7.2.300.0030.01716.34
7.2.290.0170.00616.63
7.2.60.0030.01016.51
7.2.00.0040.01119.37
7.1.200.0060.00915.61
7.1.100.0030.01018.21
7.1.70.0030.01016.99
7.1.60.0130.01319.46
7.1.50.0030.01016.86
7.1.00.0030.07722.58
7.0.200.0040.00416.81
7.0.140.0100.06321.95
7.0.60.0170.03721.75
7.0.50.0130.04317.96
7.0.40.0130.06320.41
7.0.30.0270.05020.15
7.0.20.0230.08720.22
7.0.10.0270.07720.07
7.0.00.0100.04020.22
5.6.280.0030.07321.12
5.6.210.0130.05720.64
5.6.200.0100.07718.14
5.6.190.0100.09020.63
5.6.180.3270.04020.61
5.6.170.0200.04720.50
5.6.160.0270.04020.56
5.6.150.0070.04718.18
5.6.140.0070.05018.18
5.6.130.0100.07718.19
5.6.120.0130.05021.14
5.6.110.0100.07720.91
5.6.100.0070.07321.11
5.6.90.0100.08020.98
5.6.80.0100.03320.43
5.5.350.0100.07720.49
5.5.340.0070.03318.05
5.5.330.0070.07020.27
5.5.320.0470.06720.43
5.5.310.0270.07020.37
5.5.300.0030.05017.98
5.5.290.0070.06017.96
5.5.280.0070.07020.90
5.5.270.0000.08720.78
5.5.260.0070.06720.97
5.5.250.0130.07720.48
5.5.240.0300.04720.05
5.4.450.0730.06319.63
5.4.440.0770.05019.34
5.4.430.0570.05319.33
5.4.420.0670.00019.52
5.4.410.0070.06718.86
5.4.400.0200.05318.79
5.4.390.0230.07018.77
5.4.380.0230.05018.61
5.4.370.0170.04718.48
5.4.360.0170.04718.64
5.4.350.0040.03812.04
5.4.340.0070.03612.03
5.4.320.0080.03512.52
5.4.310.0080.03512.52
5.4.300.0070.03512.52
5.4.290.0060.04912.52
5.4.280.0070.05312.41
5.4.270.0090.05212.41
5.4.260.0130.05212.42
5.4.250.0100.05512.41
5.4.240.0050.05712.41
5.4.230.0070.05412.41
5.4.220.0080.05212.41
5.4.210.0050.05312.40
5.4.200.0070.05312.41
5.4.190.0050.05112.40
5.4.180.0140.03612.40
5.4.170.0100.03512.41
5.4.160.0040.04212.41
5.4.150.0080.04012.40
5.4.140.0090.03912.09
5.4.130.0080.03612.08
5.4.120.0050.04012.04
5.4.110.0070.03812.03
5.4.100.0060.04312.03
5.4.90.0080.04412.04
5.4.80.0080.04312.03
5.4.70.0070.04012.02
5.4.60.0080.04112.03
5.4.50.0090.03912.03
5.4.40.0070.04112.02
5.4.30.0050.04312.01
5.4.20.0080.04112.02
5.4.10.0090.05212.01
5.4.00.0070.05711.51
5.3.290.0090.05412.80
5.3.280.0130.05312.71
5.3.270.0110.05212.73
5.3.260.0110.06112.72
5.3.250.0080.05212.72
5.3.240.0060.05212.72
5.3.230.0090.04412.71
5.3.220.0110.04912.68
5.3.210.0090.04112.68
5.3.200.0070.04112.68
5.3.190.0070.04012.70
5.3.180.0090.03612.68
5.3.170.0100.05012.67
5.3.160.0060.05312.67
5.3.150.0140.03512.67
5.3.140.0090.05212.66
5.3.130.0050.05012.66
5.3.120.0070.04912.66
5.3.110.0040.04812.66
5.3.100.0130.03512.15
5.3.90.0060.04212.13
5.3.80.0080.03912.12
5.3.70.0070.04112.13
5.3.60.0090.04012.11
5.3.50.0070.03912.05
5.3.40.0060.04112.06
5.3.30.0070.03712.01
5.3.20.0090.03711.79
5.3.10.0050.03911.76
5.3.00.0080.03611.75
5.2.170.0050.0339.25
5.2.160.0070.0319.25
5.2.150.0050.0379.25
5.2.140.0060.0359.25
5.2.130.0050.0419.21
5.2.120.0060.0379.21
5.2.110.0050.0449.21
5.2.100.0100.0299.21
5.2.90.0080.0399.21
5.2.80.0100.0419.20
5.2.70.0120.0349.21
5.2.60.0070.0309.16
5.2.50.0100.0279.13
5.2.40.0100.0289.10
5.2.30.0070.0329.08
5.2.20.0080.0409.07
5.2.10.0060.0358.98
5.2.00.0060.0348.84
5.1.60.0070.0288.12
5.1.50.0060.0318.12
5.1.40.0080.0268.09
5.1.30.0040.0348.45
5.1.20.0060.0338.47
5.1.10.0040.0328.20
5.1.00.0060.0288.19
5.0.50.0040.0236.67
5.0.40.0020.0226.53
5.0.30.0010.0366.34
5.0.20.0050.0246.31
5.0.10.0030.0246.29
5.0.00.0040.0346.29
4.4.90.0030.0174.77
4.4.80.0020.0184.76
4.4.70.0030.0174.76
4.4.60.0030.0184.76
4.4.50.0050.0204.77
4.4.40.0050.0324.71
4.4.30.0070.0194.76
4.4.20.0050.0214.84
4.4.10.0040.0204.85
4.4.00.0040.0314.76
4.3.110.0060.0214.67
4.3.100.0040.0224.66
4.3.90.0060.0194.64
4.3.80.0040.0314.59
4.3.70.0080.0174.63
4.3.60.0050.0204.63
4.3.50.0050.0214.63
4.3.40.0020.0324.53
4.3.30.0030.0213.30
4.3.20.0030.0213.28
4.3.10.0020.0213.23
4.3.00.0000.0237.64

preferences:
41.88 ms | 401 KiB | 5 Q