3v4l.org

run code in 300+ PHP versions simultaneously
<?php function japan_holiday_ics() { // カレンダーID $calendar_id = urlencode('japanese__ja@holiday.calendar.google.com'); $url = 'https://calendar.google.com/calendar/ical/'.$calendar_id.'/public/full.ics'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); if (!empty($result)) { $items = $sort = array(); $start = false; $count = 0; foreach(explode("\n", $result) as $row => $line) { // 1行目が「BEGIN:VCALENDAR」でなければ終了 if (0 === $row && false === stristr($line, 'BEGIN:VCALENDAR')) { break; } // 改行などを削除 $line = trim($line); // 「BEGIN:VEVENT」なら日付データの開始 if (false !== stristr($line, 'BEGIN:VEVENT')) { $start = true; } elseif ($start) { // 「END:VEVENT」なら日付データの終了 if (false !== stristr($line, 'END:VEVENT')) { $start = false; // 次のデータ用にカウントを追加 ++$count; } else { // 配列がなければ作成 if (empty($items[$count])) { $items[$count] = array('date' => null, 'title' => null); } // 「DTSTART;~」(対象日)の処理 if(0 === strpos($line, 'DTSTART;VALUE')) { $date = explode(':', $line); $date = end($date); $items[$count]['date'] = $date; // ソート用の配列にセット $sort[$count] = $date; } // 「SUMMARY:~」(名称)の処理 elseif(0 === strpos($line, 'SUMMARY:')) { list($title) = explode('/', substr($line, 8)); $items[$count]['title'] = trim($title); } } } } // 日付でソート $items = array_combine($sort, $items); ksort($items); return $items; } } japan_holiday_ics();
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/UCBho:7 Stack trace: #0 /in/UCBho(62): japan_holiday_ics() #1 {main} thrown in /in/UCBho on line 7
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.49 ms | 401 KiB | 8 Q