3v4l.org

run code in 300+ PHP versions simultaneously
<?php $apiKey = 'AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg'; $channelId = 'UC226a2gZas0iS2KUtrF7oFw'; $maxResults = 50; $results = fetchLists($apiKey, $channelId, $maxResults); function fetchLists($apiKey, $channelId, $maxResults, $listsNextPage = null, $playlists = array()) { $ytApiUrl = 'https://www.googleapis.com/youtube/v3/playlists?maxResults=' . $maxResults . '&part=snippet&channelId=' . $channelId . '&key=' . $apiKey ; if($listsNextPage !== null){ $ytApiUrl .= '&pageToken=' . $listsNextPage; } $jsonLists = json_decode(file_get_contents($ytApiUrl)); $listsPageToken = (isset($jsonLists->nextPageToken)) ? $jsonLists->nextPageToken : null ; foreach ($jsonLists->items as $item) { $plId = $item->id; $list = array( "id" => $plId, "title" => $item->snippet->title, "published" => $item->snippet->publishedAt, "url" => 'https://www.youtube.com/playlist?list=' . $plId, "thumbnail" => $item->snippet->thumbnails->default->url, "videos" => [] ); fetchVideos($list, $playlists, $maxResults, $plId, $apiKey); } if($listsPageToken !== null){ return fetchLists($apiKey, $channelId, $maxResults, $listsPageToken, $playlists); } return $playlists; } function fetchVideos(&$list, &$playlists, &$maxResults, &$plId, &$apiKey, $vidsNextPage = null) { $plApiUrl = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults='. $maxResults .'&playlistId=' . $plId . '&key=' . $apiKey; if($vidsNextPage !== null){ $plApiUrl .= '&pageToken=' . $vidsNextPage; } $jsonPlVideos = json_decode(file_get_contents($plApiUrl)); $videosPageToken = (isset($jsonPlVideos->nextPageToken)) ? $jsonPlVideos->nextPageToken : null ; foreach ($jsonPlVideos->items as $vid) { $video = array( "title" => $vid->snippet->title, "url" => 'https://www.youtube.com/watch?v=' . $vid->snippet->resourceId->videoId, "published" => $vid->snippet->publishedAt, "thumbnail" => $vid->snippet->thumbnails->default->url ); $list['videos'][] = $video; } $playlists[] = $list; if($videosPageToken !== null){ return fetchVideos($list, $playlists, $maxResults, $plId, $apiKey, $videosPageToken); } }
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): Failed to open stream: Operation not permitted in /in/qe40e on line 14 Warning: Attempt to read property "items" on null in /in/qe40e on line 16 Warning: foreach() argument must be of type array|object, null given in /in/qe40e on line 16
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): Failed to open stream: Operation not permitted in /in/qe40e on line 14 Warning: Attempt to read property "items" on null in /in/qe40e on line 16 Warning: foreach() argument must be of type array|object, null given in /in/qe40e on line 16
Output for 8.0.13
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): Failed to open stream: No such file or directory in /in/qe40e on line 14 Warning: Attempt to read property "items" on null in /in/qe40e on line 16 Warning: foreach() argument must be of type array|object, null given in /in/qe40e on line 16
Output for 7.4.33
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): failed to open stream: No such file or directory in /in/qe40e on line 14 Notice: Trying to get property 'items' of non-object in /in/qe40e on line 16 Warning: Invalid argument supplied for foreach() in /in/qe40e on line 16
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): failed to open stream: Operation not permitted in /in/qe40e on line 14 Notice: Trying to get property 'items' of non-object in /in/qe40e on line 16 Warning: Invalid argument supplied for foreach() in /in/qe40e on line 16
Output for 7.3.32 - 7.3.33
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): failed to open stream: No such file or directory in /in/qe40e on line 14 Warning: Invalid argument supplied for foreach() in /in/qe40e on line 16
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/qe40e on line 14 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qe40e on line 14 Warning: file_get_contents(https://www.googleapis.com/youtube/v3/playlists?maxResults=50&part=snippet&channelId=UC226a2gZas0iS2KUtrF7oFw&key=AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg): failed to open stream: Operation not permitted in /in/qe40e on line 14 Notice: Trying to get property of non-object in /in/qe40e on line 16 Warning: Invalid argument supplied for foreach() in /in/qe40e on line 16

preferences:
230.68 ms | 404 KiB | 291 Q