3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * 公共控制器 * Created by Mini * Time:2014-10-17 15:52:10 * * ┏┓ ┏┓ * ┏┛┻━━━━━━┻┗┓ * ┃ ┃ * ┃ ━ ┃ * ┃ ┳┛ ┗┳ ┃ * ┃ ┃ * ┃ ┻ ┃ * ┗━┓ ┏━┛ * ┃ ┃ 神兽保佑,代码无忧! * ┏━━━┛ ┃ 从此代码再无BUG! * ┏┫ ┃ ORZ ORZ ORZ ORZ....... * ┗┓ ┃ * ┗┓┏┳━━━┓ ┏┏┛ * ┣┣┃ ┣┣┃ * ┗┻┛ ┗┻┛ * */ class CreateOauth { protected $appid; //公众平台AppID protected $appsecret; //公众平台AppSecret; protected $curl_timeout; //CRUL超时时间 默认30S protected $code; //Oauth认证 回调Code protected $flag; //Oauth认证的模式 //false-->不弹出授权页面,直接跳转,只能获取用户openid //true-->弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 protected $access_token; public function __construct ($appid = '', $appsecret = '', $curl_timeout = 30, $flag = false) { if ($appid == '' || $appsecret == '') { return false; } $this->appid = $appid; $this->appsecret = $appsecret; $this->curl_timeout = $curl_timeout; $this->flag = $flag; } /** * 作用:生成可以获得code的url */ public function createOauthUrlForCode ($redirectUrl = '') { if ($redirectUrl == '') return false; $urlObj['appid'] = $this->appid; $urlObj['redirect_uri'] = urlencode($redirectUrl); $urlObj['response_type'] = 'code'; if ($this->flag) { $urlObj["scope"] = "snsapi_userinfo"; //弹出授权页面 } else { $urlObj["scope"] = "snsapi_base"; //不弹出授权页面 } $urlObj["state"] = "STATE"."#wechat_redirect"; $bizString = $this->formatPara($urlObj); $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?'.$bizString; return $url; } /** * 作用:生成可以获得openid的url */ public function createOauthUrlForOpenid () { $urlObj["appid"] = $this->appid; $urlObj["secret"] = $this->appsecret; $urlObj["code"] = $this->code; $urlObj["grant_type"] = "authorization_code"; $bizString = $this->formatPara($urlObj); return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString; } /** * 作用:生成可以获得用户详细信息的URL */ public function createUrlForUserInfo () { $urlObj["access_token"] = $this->access_token; $urlObj["openid"] = $this->openid; $urlObj["lang"] = 'zh_CN '; $bizString = $this->formatPara($urlObj); return "https://api.weixin.qq.com/sns/userinfo?".$bizString; } /** * 作用:设置code */ public function setCode ($code_) { $this->code = $code_; } /** * 作用:通过curl向微信提交code,以获取openid */ public function getOpenid () { $url = $this->createOauthUrlForOpenid(); //初始化curl $ch = curl_init(); //设置超时 curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_timeout); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //运行curl,结果以jason形式返回 $res = curl_exec($ch); curl_close($ch); //取出openid $data = json_decode($res,true); $this->openid = $data['openid']; $this->access_token = $data['access_token']; return $this->openid; } /** * 作用:通过curl获取用户信息 */ public function getUserInfo () { $this->getOpenid(); $url = $this->createUrlForUserInfo(); //初始化curl $ch = curl_init(); //设置超时 curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_timeout); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //运行curl,结果以jason形式返回 $res = curl_exec($ch); curl_close($ch); //取出openid $data = json_decode($res,true); return $data; } /** * 作用:生成参数 */ protected function formatPara ($paraMap) { $buff = ''; foreach ($paraMap as $k => $v) { $buff .= $k . '=' . $v . '&'; } $reqPar = ''; if (strlen($buff) > 0) { $reqPar = substr($buff, 0, strlen($buff)-1); } return $reqPar; } }

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.4.130.0130.00817.68
8.4.120.0140.00620.55
8.4.110.0070.00318.58
8.4.100.0060.00317.55
8.4.90.0070.01318.55
8.4.80.0130.00717.45
8.4.70.0130.00817.71
8.4.60.0110.00918.88
8.4.50.0030.00620.43
8.4.40.0170.00317.62
8.4.30.0030.01717.52
8.4.20.0100.01017.67
8.4.10.0040.00417.55
8.3.260.0120.00716.63
8.3.250.0070.00219.24
8.3.240.0100.01016.54
8.3.230.0100.01016.70
8.3.220.0070.01317.05
8.3.210.0080.01117.97
8.3.200.0060.00316.66
8.3.190.0050.00517.25
8.3.180.0100.00818.72
8.3.170.0090.01020.61
8.3.160.0130.00618.75
8.3.150.0030.01317.19
8.3.140.0130.00616.55
8.3.130.0060.00318.46
8.3.120.0060.01320.74
8.3.110.0040.00420.94
8.3.100.0040.00416.63
8.3.90.0120.00626.77
8.3.80.0000.01019.36
8.3.70.0110.01117.95
8.3.60.0150.00016.63
8.3.50.0070.01322.99
8.3.40.0070.01418.73
8.3.30.0110.00719.09
8.3.20.0000.00820.21
8.3.10.0040.00420.23
8.3.00.0000.00819.18
8.2.290.0080.01120.07
8.2.280.0070.00318.19
8.2.270.0150.00316.79
8.2.260.0040.00416.54
8.2.250.0050.00318.22
8.2.240.0090.00918.51
8.2.230.0050.00322.58
8.2.220.0040.00437.54
8.2.210.0000.00726.77
8.2.200.0060.00318.88
8.2.190.0070.01418.29
8.2.180.0140.00718.16
8.2.170.0110.00418.65
8.2.160.0060.00922.17
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0000.00726.16
8.2.120.0060.00319.11
8.2.110.0060.00321.89
8.2.100.0070.00717.66
8.2.90.0000.00919.82
8.2.80.0040.00417.97
8.2.70.0050.00317.38
8.2.60.0080.00017.80
8.2.50.0040.00418.07
8.2.40.0040.00418.09
8.2.30.0000.00721.18
8.2.20.0030.00517.75
8.2.10.0000.00817.95
8.2.00.0040.00417.57
8.1.330.0120.00623.73
8.1.320.0130.01117.55
8.1.310.0080.00016.31
8.1.300.0120.00319.97
8.1.290.0090.00030.84
8.1.280.0040.01125.92
8.1.270.0040.00421.88
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0060.00320.27
8.1.230.0070.00717.82
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0030.00617.35
8.1.190.0040.00417.43
8.1.180.0080.00018.10
8.1.170.0080.00018.41
8.1.160.0040.00418.90
8.1.150.0000.00718.94
8.1.140.0080.00017.49
8.1.130.0040.00417.76
8.1.120.0030.00317.36
8.1.110.0050.00217.47
8.1.100.0040.00417.41
8.1.90.0020.00517.46
8.1.80.0000.00717.38
8.1.70.0000.00717.40
8.1.60.0000.00817.42
8.1.50.0000.00817.46
8.1.40.0060.00317.46
8.1.30.0080.00017.50
8.1.20.0000.00717.58
8.1.10.0050.00317.44
8.1.00.0030.00617.36
8.0.300.0040.00418.77
8.0.290.0060.00316.75
8.0.280.0040.00418.45
8.0.270.0040.00416.88
8.0.260.0030.00317.14
8.0.250.0000.00716.93
8.0.240.0030.00316.77
8.0.230.0070.00016.89
8.0.220.0030.00316.76
8.0.210.0000.00816.87
8.0.200.0000.00616.80
8.0.190.0000.00816.89
8.0.180.0040.00416.86
8.0.170.0040.00416.86
8.0.160.0040.00416.83
8.0.150.0070.00016.70
8.0.140.0000.00716.81
8.0.130.0000.00713.36
8.0.120.0000.00816.80
8.0.110.0000.00716.80
8.0.100.0000.00716.90
8.0.90.0000.00716.88
8.0.80.0040.01216.82
8.0.70.0040.00416.84
8.0.60.0040.00416.75
8.0.50.0000.00716.88
8.0.30.0190.00516.91
8.0.20.0080.01017.40
8.0.10.0000.00817.03
8.0.00.0130.00616.71
7.4.330.0060.00015.02
7.4.320.0000.00616.54
7.4.300.0070.00016.36
7.4.290.0070.00016.60
7.4.280.0040.00416.34
7.4.270.0030.00316.53
7.4.260.0030.00716.57
7.4.250.0040.00416.44
7.4.240.0040.00316.51
7.4.230.0050.00216.53
7.4.220.0110.00716.55
7.4.210.0130.00316.46
7.4.200.0030.00316.43
7.4.160.0060.01616.64
7.4.150.0140.00717.40
7.4.140.0120.01017.86
7.4.130.0070.01016.42
7.4.120.0080.00916.46
7.4.110.0090.00916.47
7.4.100.0070.01016.39
7.4.90.0040.01516.48
7.4.80.0050.01216.41
7.4.70.0120.00616.42
7.4.60.0070.01016.32
7.4.50.0000.00816.39
7.4.40.0110.00616.64
7.4.30.0090.01316.45
7.4.10.0080.01015.58
7.4.00.0080.00815.35
7.3.330.0000.00613.25
7.3.320.0030.00313.19
7.3.310.0000.00716.27
7.3.300.0060.00016.25
7.3.290.0080.00816.20
7.3.280.0100.00716.26
7.3.270.0100.00717.40
7.3.260.0130.00716.18
7.3.250.0150.00416.41
7.3.240.0170.00016.30
7.3.230.0090.01416.39
7.3.210.0100.01016.36
7.3.200.0130.01019.39
7.3.190.0060.01316.21
7.3.180.0130.00616.56
7.3.170.0160.00016.54
7.3.160.0100.01016.41
7.3.130.0030.01515.59
7.3.120.0070.00415.53
7.3.110.0030.01215.62
7.3.100.0070.01015.53
7.3.90.0050.01115.57
7.3.80.0060.01015.42
7.3.70.0050.01015.51
7.3.60.0070.00915.55
7.3.50.0030.00915.55
7.3.40.0090.00515.40
7.3.30.0060.00815.44
7.3.20.0020.01017.25
7.3.10.0090.00517.31
7.3.00.0030.01217.35
7.2.330.0060.01216.28
7.2.320.0070.01316.20
7.2.310.0100.00616.63
7.2.300.0130.00316.59
7.2.290.0030.01416.17
7.2.260.0080.01015.61
7.2.250.0090.01015.67
7.2.240.0070.00915.73
7.2.230.0070.00815.46
7.2.220.0080.01015.68
7.2.210.0020.01315.65
7.2.200.0050.01015.49
7.2.190.0050.00715.67
7.2.180.0060.00915.74
7.2.170.0050.01015.45
7.2.160.0020.01015.59
7.2.150.0050.01017.43
7.2.140.0080.00517.43
7.2.130.0050.00817.46
7.2.120.0060.00617.56
7.2.110.0070.00917.51
7.2.100.0080.00817.44
7.2.90.0070.00517.42
7.2.80.0030.01117.40
7.2.70.0020.01317.39
7.2.60.0060.00917.09
7.2.50.0030.01317.34
7.2.40.0060.00817.52
7.2.30.0030.01217.52
7.2.20.0030.01017.39
7.2.10.0070.01017.48
7.2.00.0080.00717.97
7.1.330.0070.00716.20
7.1.320.0020.00916.27
7.1.310.0050.00916.47
7.1.300.0050.00616.42
7.1.290.0050.01016.37
7.1.280.0070.00416.37
7.1.270.0050.00816.21
7.1.260.0060.00916.28
7.1.250.0050.00916.19
7.1.240.0020.01216.31
7.1.230.0040.01116.26
7.1.220.0030.00916.36
7.1.210.0080.00816.30
7.1.200.0050.00716.13
7.1.190.0060.00616.39
7.1.180.0060.00816.35
7.1.170.0050.00916.26
7.1.160.0030.01116.36
7.1.150.0050.00916.29
7.1.140.0070.00716.29
7.1.130.0070.00616.43
7.1.120.0050.01216.33
7.1.110.0040.00916.52
7.1.100.0070.00516.89
7.1.90.0050.00816.37
7.1.80.0020.01216.34
7.1.70.0070.00816.64
7.1.60.0030.01317.19
7.1.50.0070.01116.60
7.1.40.0080.00716.52
7.1.30.0000.01516.44
7.1.20.0040.01116.24
7.1.10.0050.00816.37
7.1.00.0030.03118.26
7.0.330.0030.00816.01
7.0.320.0060.00616.14
7.0.310.0020.01016.00
7.0.300.0080.00315.88
7.0.290.0050.00816.06
7.0.280.0020.01215.90
7.0.270.0020.01016.08
7.0.260.0050.00715.89
7.0.250.0060.00616.05
7.0.240.0060.00716.14
7.0.230.0060.00916.04
7.0.220.0040.00916.01
7.0.210.0050.00816.00
7.0.200.0200.01015.54
7.0.190.0060.00616.06
7.0.180.0050.01115.81
7.0.170.0110.00415.91
7.0.160.0040.00816.14
7.0.150.0040.00615.98
7.0.140.0100.02618.06
7.0.130.0020.00916.00
7.0.120.0070.00716.17
7.0.110.0020.01016.01
7.0.100.0060.00516.02
7.0.90.0090.00415.94
7.0.80.0090.00516.11
7.0.70.0080.00516.08
7.0.60.0060.02617.99
7.0.50.0060.02316.59
7.0.40.0100.02816.07
7.0.30.0110.02416.13
7.0.20.0080.02316.21
7.0.10.0040.02516.02
7.0.00.0020.03716.09
5.6.400.0060.00914.98
5.6.390.0100.00614.95
5.6.380.0020.01115.15
5.6.370.0030.01015.07
5.6.360.0060.00614.88
5.6.350.0060.00814.97
5.6.340.0060.00615.02
5.6.330.0050.00414.98
5.6.320.0080.00314.93
5.6.310.0060.00614.85
5.6.300.0040.00914.87
5.6.290.0040.01114.88
5.6.280.0070.02816.79
5.6.270.0060.00714.89
5.6.260.0050.00815.06
5.6.250.0080.00814.97
5.6.240.0080.00514.81
5.6.230.0020.01014.96
5.6.220.0030.01215.03
5.6.210.0070.02516.89
5.6.200.0080.03115.92
5.6.190.0040.03416.73
5.6.180.0090.02416.73
5.6.170.0110.02716.68
5.6.160.0080.03216.78
5.6.150.0090.03216.04
5.6.140.0060.03215.98
5.6.130.0040.02216.19
5.6.120.0070.03316.99
5.6.110.0090.03016.95
5.6.100.0140.01416.98
5.6.90.0090.03216.98
5.6.80.0050.02016.68
5.6.70.0060.00814.84
5.6.60.0060.01014.75
5.6.50.0110.00414.89
5.6.40.0030.01114.86
5.6.30.0000.01114.76
5.6.20.0060.00914.82
5.6.10.0030.01114.96
5.6.00.0050.01014.90
5.5.380.0050.00614.90
5.5.370.0020.01014.76
5.5.360.0050.00914.87
5.5.350.0050.03316.77
5.5.340.0080.02015.95
5.5.330.0060.02816.55
5.5.320.0170.02216.73
5.5.310.0080.02016.65
5.5.300.0040.02015.77
5.5.290.0090.03115.97
5.5.280.0070.02816.94
5.5.270.0090.02816.76
5.5.260.0020.02216.76
5.5.250.0080.01716.72
5.5.240.0090.02616.68
5.5.230.0030.01014.64
5.5.220.0030.00814.98
5.5.210.0050.00814.57
5.5.200.0030.01114.76
5.5.190.0060.00714.82
5.5.180.0030.00814.79
5.5.170.0070.00814.76
5.5.160.0060.01014.79
5.5.150.0080.00814.78
5.5.140.0070.00714.91
5.5.130.0090.00614.71
5.5.120.0080.00414.59
5.5.110.0050.00814.61
5.5.100.0070.00514.69
5.5.90.0060.00914.61
5.5.80.0060.00814.71
5.5.70.0090.00614.79
5.5.60.0030.01014.87
5.5.50.0030.01014.79
5.5.40.0050.01014.72
5.5.30.0020.01314.83
5.5.20.0060.00914.86
5.5.10.0040.01114.72
5.5.00.0080.00614.73
5.4.450.0040.02014.92
5.4.440.0080.03214.92
5.4.430.0050.01814.97
5.4.420.0070.02615.02
5.4.410.0040.02015.01
5.4.400.0080.02914.80
5.4.390.0020.02514.81
5.4.380.0070.02114.91
5.4.370.0040.02214.91
5.4.360.0080.02414.94
5.4.350.0060.02014.82
5.4.340.0060.03014.90
5.4.330.0050.00612.79
5.4.320.0040.02614.85
5.4.310.0060.02714.94
5.4.300.0010.03114.91
5.4.290.0080.02614.85
5.4.280.0050.02414.94
5.4.270.0070.01414.89
5.4.260.0110.02214.82
5.4.250.0040.01714.82
5.4.240.0050.02314.86
5.4.230.0050.02114.90
5.4.220.0040.02514.85
5.4.210.0030.02314.93
5.4.200.0040.02414.81
5.4.190.0010.01914.81
5.4.180.0060.01814.94
5.4.170.0070.01814.82
5.4.160.0040.02714.92
5.4.150.0060.02914.90
5.4.140.0040.02414.03
5.4.130.0030.03214.00
5.4.120.0090.02713.99
5.4.110.0040.01913.96
5.4.100.0060.01913.97
5.4.90.0040.03414.00
5.4.80.0030.01713.96
5.4.70.0040.02713.97
5.4.60.0090.02314.00
5.4.50.0040.03013.97
5.4.40.0050.01813.99
5.4.30.0040.01814.02
5.4.20.0020.01713.97
5.4.10.0020.01913.97
5.4.00.0020.02013.82
5.3.290.0100.06714.70
5.3.280.0030.08014.68
5.3.270.0170.06314.70
5.3.260.0170.07014.53
5.3.250.0170.06714.65
5.3.240.0070.06714.70
5.3.230.0070.07714.70
5.3.220.0100.06014.49
5.3.210.0130.07014.76
5.3.200.0030.05014.53
5.3.190.0070.06014.64
5.3.180.0100.03314.48
5.3.170.0030.03714.49
5.3.160.0070.07314.61
5.3.150.0030.05314.64
5.3.140.0070.04714.64
5.3.130.0030.03714.64
5.3.120.0030.04314.51
5.3.110.0070.03314.66
5.3.100.0000.04014.15
5.3.90.0030.03714.11
5.3.80.0070.03014.05
5.3.70.0030.04014.13
5.3.60.0030.04014.19
5.3.50.0030.04013.99
5.3.40.0030.03714.13
5.3.30.0000.03714.11
5.3.20.0030.03313.74
5.3.10.0030.03313.83
5.3.00.0070.03313.60
5.2.170.0000.03011.08
5.2.160.0000.03011.23
5.2.150.0000.03011.11
5.2.140.0030.02711.18
5.2.130.0000.03011.10
5.2.120.0070.02311.04
5.2.110.0030.02711.29
5.2.100.0030.02711.06
5.2.90.0000.03011.24
5.2.80.0030.03011.12
5.2.70.0030.03311.21
5.2.60.0030.02711.24
5.2.50.0070.03011.05
5.2.40.0000.03011.06
5.2.30.0000.03310.98
5.2.20.0000.03011.04
5.2.10.0030.02710.90
5.2.00.0000.03010.77
5.1.60.0000.02710.06
5.1.50.0070.02010.12
5.1.40.0030.02310.07
5.1.30.0000.02710.53
5.1.20.0030.02710.48
5.1.10.0070.02010.27
5.1.00.0000.02710.09
5.0.50.0030.0178.66
5.0.40.0030.0178.55
5.0.30.0070.0238.28
5.0.20.0100.0108.42
5.0.10.0000.0208.28
5.0.00.0000.0308.20
4.4.90.0000.0177.33
4.4.80.0000.0177.33
4.4.70.0030.0137.33
4.4.60.0030.0137.33
4.4.50.0000.0177.33
4.4.40.0000.0237.33
4.4.30.0030.0137.33
4.4.20.0000.0177.33
4.4.10.0000.0177.33
4.4.00.0000.0277.33
4.3.110.0030.0107.33
4.3.100.0000.0137.33
4.3.90.0000.0137.33
4.3.80.0030.0237.33
4.3.70.0070.0077.33
4.3.60.0000.0137.33
4.3.50.0000.0137.33
4.3.40.0000.0237.33
4.3.30.0030.0137.33
4.3.20.0000.0137.33
4.3.10.0000.0177.33
4.3.00.0030.0207.33

preferences:
141.75 ms | 403 KiB | 5 Q