3v4l.org

run code in 300+ PHP versions simultaneously
<?php $now = date('Y-m-d h:20'); $today = date('Y-m-d'); $afternoon = date('Y-m-d 17:27'); // require Facebook PHP SDK // see: https://developers.facebook.com/docs/php/gettingstarted/ require_once("sdk/facebook.php"); // initialize Facebook class using your own Facebook App credentials // see: https://developers.facebook.com/docs/php/gettingstarted/#install $config = array(); $config['appId'] = '290692250950652'; // configure appropriately $config['secret'] = 'b796627dc623cee90ac49ac806d6b4e8'; // configure appropriately $config['fileUpload'] = false; // optional $fb = new Facebook($config); $user_id="1740048734"; $page_id="127287113972280"; $group_id="115454235207375"; $user_token = array(); $page_token = array(); $user_token['access_token'] = 'CAAEIYhBbWZCwBAEkHQxFNWkdVY52PGapKqccqQX2QlLHM2pqZB1dR7oumasYUhCkAZCW95Ab4f3HmzpPygWXkrHk0fl1t1iaGlfyaCjG04B8shEx3Bp3VzVakM5xZAFBUOLZB3T8TirYWwAGrZBrAEexymrA5YXGYMFgipex0Ho1kmt3BWdhVebcU2GLPJBiMZD'; $fb->setAccessToken($user_token['access_token']); $accounts = $fb->api('/'.$user_id.'/accounts'); foreach($accounts['data'] as $account){ if($account['id'] == $page_id){ $page_token['access_token'] = $account['access_token']; } } $conn = new mysqli("localhost", "mvawzuyw_admin", "#veyron_153", "mvawzuyw_sharecenter"); if ($conn->connect_error) { trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); } // create array with topics to be posted on Facebook $sql = 'SELECT * FROM queue WHERE date IS NOT NULL AND count > 0 ORDER BY date ASC'; $rs = $conn->query($sql); if($rs === false) { $user_error = 'Wrong SQL: ' . $sql . '<br>' . 'Error: ' . $conn->errno . ' ' . $conn->error; trigger_error($user_error, E_USER_ERROR); } $rs->data_seek(0); $share_topics = array(); while($res = $rs->fetch_assoc()) { $a_topic = array( "url" => $res["url"], "title" => $res["title"], "message" => $res["message"], "description" => $res["description"], "image" => $res["image"], "targets" => $res["targets"], "event_date" => $res["event_date"], "photo" => $res["photo"], "count" => $res["count"], "date" => $res["date"] ); array_push($share_topics, $a_topic); } $rs->free(); foreach($share_topics as $share_topic) { if($share_topic['date'] == $now ) { // define POST parameters $content = array( "message" => $share_topic["message"], "link" => $share_topic["url"], "name" => $share_topic["title"], "caption" => "https://sekazone.ro", // configure appropriately "description" => $share_topic["description"] ); try { $ret = $fb->api('/'.$page_id.'/feed', 'POST', array_merge($page_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(10); try { $ret = $fb->api('/'.$user_id.'/feed', 'POST', array_merge($user_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(10); try { $ret = $fb->api('/'.$group_id.'/feed', 'POST', array_merge($user_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(10); foreach ($share_topic['targets'] as $value) { try { $ret = $fb->api('/'.$value.'/feed', 'POST', array_merge($user_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(25); } $share_topic["count"] = $share_topic["count"] -1; $sql = 'UPDATE queue SET count = '.$share_topic['count'].' WHERE url = ' . $share_topic['url']; if($conn->query($sql) === false) : trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); endif; // IS TODAY __________________________________________________________________ } elseif ($share_topic['event_date'] == $today && $now == $afternoon) { $content = array( "message" => $share_topic["message"], "link" => $share_topic["url"], "name" => $share_topic["title"], "caption" => "https://sekazone.ro", // configure appropriately "description" => $share_topic["description"] ); try { $ret = $fb->api('/'.$page_id.'/feed', 'POST', array_merge($page_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(10); try { $ret = $fb->api('/'.$user_id.'/feed', 'POST', array_merge($user_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(10); try { $ret = $fb->api('/'.$group_id.'/feed', 'POST', array_merge($user_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(10); foreach ($share_topic['targets'] as $value) { try { $ret = $fb->api('/'.$value.'/feed', 'POST', array_merge($user_token, $content)); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } sleep(25); } $share_topic["count"] = $share_topic["count"] -1; $sql = 'UPDATE queue SET count = '.$share_topic['count'].' WHERE url = ' . $share_topic['url']; if($conn->query($sql) === false) : trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); endif; } } ?>

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.70.0130.00617.00
8.3.60.0100.01318.55
8.3.50.0060.01022.00
8.3.40.0040.01119.16
8.3.30.0090.00619.52
8.3.20.0080.00020.47
8.3.10.0040.00421.92
8.3.00.0030.00522.34
8.2.180.0120.00916.88
8.2.170.0070.00722.96
8.2.160.0040.01821.06
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0060.00319.36
8.2.110.0070.00322.14
8.2.100.0120.00017.97
8.2.90.0040.00419.30
8.2.80.0000.00818.29
8.2.70.0090.00317.62
8.2.60.0000.00818.05
8.2.50.0040.00418.07
8.2.40.0040.00418.28
8.2.30.0040.00418.25
8.2.20.0050.00317.84
8.2.10.0080.00017.80
8.2.00.0000.00717.95
8.1.280.0060.01225.92
8.1.270.0040.00423.96
8.1.260.0050.00526.35
8.1.250.0080.00028.09
8.1.240.0060.00323.96
8.1.230.0040.00819.23
8.1.220.0090.00017.91
8.1.210.0050.00318.77
8.1.200.0030.00617.36
8.1.190.0030.00617.79
8.1.180.0060.00318.10
8.1.170.0050.00318.77
8.1.160.0000.00722.11
8.1.150.0000.00818.78
8.1.140.0040.00417.71
8.1.130.0050.00218.04
8.1.120.0000.00717.70
8.1.110.0040.00417.61
8.1.100.0000.00717.68
8.1.90.0070.00017.64
8.1.80.0040.00417.77
8.1.70.0000.00717.73
8.1.60.0030.00617.73
8.1.50.0060.00317.68
8.1.40.0040.00417.81
8.1.30.0070.00417.88
8.1.20.0080.00017.89
8.1.10.0000.00817.71
8.1.00.0000.00817.80
8.0.300.0000.00718.77
8.0.290.0000.00817.29
8.0.280.0000.00818.70
8.0.270.0000.00717.57
8.0.260.0080.00317.11
8.0.250.0030.00317.36
8.0.240.0040.00417.30
8.0.230.0000.00717.25
8.0.220.0070.00017.15
8.0.210.0020.00517.19
8.0.200.0030.00317.27
8.0.190.0040.00417.30
8.0.180.0060.00317.17
8.0.170.0030.00517.15
8.0.160.0000.00817.24
8.0.150.0000.00717.15
8.0.140.0000.00817.21
8.0.130.0060.00013.50
8.0.120.0000.00817.16
8.0.110.0050.00317.20
8.0.100.0000.00717.13
8.0.90.0040.00417.02
8.0.80.0100.00717.25
8.0.70.0080.00017.26
8.0.60.0070.00017.25
8.0.50.0050.00317.16
8.0.30.0100.00917.40
8.0.20.0140.00517.42
8.0.10.0000.00917.23
8.0.00.0150.00617.18
7.4.330.0000.00515.15
7.4.320.0040.00416.66
7.4.300.0000.00616.70
7.4.290.0030.00316.73
7.4.280.0050.00316.74
7.4.270.0000.00716.75
7.4.260.0040.00416.58
7.4.250.0000.00816.74
7.4.240.0050.00316.79
7.4.230.0070.00016.80
7.4.220.0110.01516.59
7.4.210.0070.00816.77
7.4.200.0000.00816.70
7.4.190.0000.00816.87
7.4.160.0100.00716.60
7.4.150.0140.00717.40
7.4.140.0090.01517.86
7.4.130.0080.01016.72
7.4.120.0110.00816.74
7.4.110.0040.01616.77
7.4.100.0100.00716.67
7.4.90.0090.00916.68
7.4.80.0080.01119.39
7.4.70.0070.01016.89
7.4.60.0030.01316.79
7.4.50.0060.00316.79
7.4.40.0090.00622.77
7.4.30.0100.00716.65
7.4.00.0110.00315.05
7.3.330.0000.00513.31
7.3.320.0050.00013.38
7.3.310.0040.00416.54
7.3.300.0000.00916.49
7.3.290.0110.00316.47
7.3.280.0110.00616.47
7.3.270.0130.00617.40
7.3.260.0060.01316.80
7.3.250.0170.00516.45
7.3.240.0000.01716.43
7.3.230.0090.00916.61
7.3.210.0070.01016.51
7.3.200.0070.01719.39
7.3.190.0030.01516.66
7.3.180.0100.00716.51
7.3.170.0070.01016.56
7.3.160.0060.00916.46
7.3.120.0040.01114.75
7.3.110.0040.00715.07
7.3.100.0070.00415.18
7.3.90.0030.01015.10
7.3.80.0060.01014.78
7.3.70.0060.00915.02
7.3.60.0040.01214.96
7.3.50.0000.01214.89
7.3.40.0100.00315.03
7.3.30.0070.00714.77
7.3.20.0060.00916.75
7.3.10.0040.01416.55
7.3.00.0080.00416.79
7.2.330.0130.00616.90
7.2.320.0140.01216.87
7.2.310.0070.01016.75
7.2.300.0120.00616.68
7.2.290.0040.01516.67
7.2.240.0060.00915.41
7.2.230.0040.01515.12
7.2.220.0090.00615.37
7.2.210.0000.01615.18
7.2.200.0060.00615.33
7.2.190.0000.01715.07
7.2.180.0070.01115.34
7.2.170.0120.00315.28
7.2.160.0030.01215.08
7.2.150.0030.01416.93
7.2.140.0070.00717.03
7.2.130.0110.00716.70
7.2.120.0030.01216.77
7.2.110.0070.00716.90
7.2.100.0060.00916.84
7.2.90.0100.00716.83
7.2.80.0080.00416.89
7.2.70.0060.01017.11
7.2.60.0090.00617.05
7.2.50.0030.00916.88
7.2.40.0090.00616.85
7.2.30.0060.00917.02
7.2.20.0000.01216.98
7.2.10.0060.01017.08
7.2.00.0070.00918.08
7.1.330.0030.00915.82
7.1.320.0030.01015.84
7.1.310.0130.00015.52
7.1.300.0030.01315.50
7.1.290.0100.00715.71
7.1.280.0030.01215.59
7.1.270.0060.00615.59
7.1.260.0070.00715.88
7.1.250.0030.01215.83
7.1.100.0060.00617.93
7.1.70.0070.01117.08
7.1.60.0060.01919.82
7.1.50.0070.01516.65
7.1.00.0000.08022.48
7.0.200.0090.00316.39
7.0.140.0030.07722.03
7.0.90.0070.04720.12
7.0.80.0100.06720.08
7.0.70.0130.07320.08
7.0.60.0000.06320.18
7.0.50.0130.07320.41
7.0.40.0130.03320.14
7.0.30.0000.08720.04
7.0.20.0100.08720.14
7.0.10.0030.05720.10
7.0.00.0030.05320.12
5.6.280.0100.06720.98
5.6.240.0000.06320.56
5.6.230.0030.06020.55
5.6.220.0000.09320.66
5.6.210.0030.04720.64
5.6.200.0200.07021.08
5.6.190.0170.06721.13
5.6.180.0100.08021.14
5.6.170.0070.07021.05
5.6.160.0130.07321.04
5.6.150.0070.06721.07
5.6.140.0030.09321.18
5.6.130.0000.09321.10
5.6.120.0130.07321.16
5.6.110.0000.05021.04
5.6.100.0030.08721.08
5.6.90.0070.05321.11
5.6.80.0100.08020.41
5.6.70.0100.07720.38
5.6.60.0070.06020.46
5.6.50.0000.05320.46
5.6.40.0070.07020.45
5.6.30.0070.07320.48
5.6.20.0100.08020.34
5.6.10.0130.07020.52
5.6.00.0100.07720.44
5.5.380.0070.03720.48
5.5.370.0130.08020.45
5.5.360.0000.06720.61
5.5.350.0100.08720.47
5.5.340.0030.05320.98
5.5.330.0030.05320.98
5.5.320.0070.05020.85
5.5.310.0200.07320.81
5.5.300.0100.08020.85
5.5.290.0030.08320.88
5.5.280.0070.06020.79
5.5.270.0100.06320.76
5.5.260.0130.07020.96
5.5.250.0230.06320.51
5.5.240.0100.08320.21
5.5.230.0070.07320.29
5.5.220.0100.07320.36
5.5.210.0130.06720.32
5.5.200.0070.07720.24
5.5.190.0070.06020.33
5.5.180.0200.06720.23
5.5.160.0030.05320.30
5.5.150.0100.07020.21
5.5.140.0030.07720.26
5.5.130.0100.04320.26
5.5.120.0000.05020.20
5.5.110.0170.06720.29
5.5.100.0000.08320.07
5.5.90.0100.04720.16
5.5.80.0070.06720.12
5.5.70.0100.05320.09
5.5.60.0130.04320.11
5.5.50.0030.05720.11
5.5.40.0030.05320.14
5.5.30.0130.04720.07
5.5.20.0000.04319.98
5.5.10.0000.06320.11
5.5.00.0130.07720.16
5.4.450.0000.08319.38
5.4.440.0070.03319.45
5.4.430.0070.08019.31
5.4.420.0100.07719.26
5.4.410.0100.06019.00
5.4.400.0070.05719.17
5.4.390.0100.05319.10
5.4.380.0070.07318.96
5.4.370.0070.08318.91
5.4.360.0070.07019.05
5.4.350.0030.07019.11
5.4.340.0070.08019.11
5.4.320.0130.03719.13
5.4.310.0100.07019.05
5.4.300.0070.08019.03
5.4.290.0000.05018.98
5.4.280.0070.07319.23
5.4.270.0070.04019.03
5.4.260.0030.04719.08
5.4.250.0030.04718.81
5.4.240.0070.06318.90
5.4.230.0070.06718.83
5.4.220.0100.08018.98
5.4.210.0070.04319.14
5.4.200.0000.07718.96
5.4.190.0130.07018.89
5.4.180.0130.03719.07
5.4.170.0100.04019.12
5.4.160.0100.06718.77
5.4.150.0070.06319.01
5.4.140.0030.04016.42
5.4.130.0000.04016.42
5.4.120.0100.05316.40
5.4.110.0030.04716.28
5.4.100.0130.02716.32
5.4.90.0030.07716.51
5.4.80.0030.08016.25
5.4.70.0170.06316.25
5.4.60.0030.07316.30
5.4.50.0070.03016.34
5.4.40.0100.06016.25
5.4.30.0000.03016.34
5.4.20.0000.06316.46
5.4.10.0030.07316.44
5.4.00.0000.05015.86
5.3.290.0070.07314.67
5.3.280.0070.07714.51
5.3.270.0070.07014.62
5.3.260.0100.04014.52
5.3.250.0000.06714.48
5.3.240.0070.07314.67
5.3.230.0130.03314.66
5.3.220.0030.06014.48
5.3.210.0100.03014.49
5.3.200.0070.05014.59
5.3.190.0000.06714.53
5.3.180.0030.06314.45
5.3.170.0100.04314.44
5.3.160.0030.03714.61
5.3.150.0030.04314.48
5.3.140.0000.06314.62
5.3.130.0000.08314.60
5.3.120.0070.05014.59
5.3.110.0030.06014.59
5.3.100.0000.05713.91
5.3.90.0100.05713.91
5.3.80.0070.06314.01
5.3.70.0170.05714.03
5.3.60.0000.07313.93
5.3.50.0000.08313.86
5.3.40.0000.09013.98
5.3.30.0070.08013.93
5.3.20.0070.07313.66
5.3.10.0030.07313.66
5.3.00.0030.06013.55

preferences:
48.98 ms | 401 KiB | 5 Q