3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { public const PATH_TO_FILES = __DIR_.'../dpm/oc-content/uploads/28/'; public function __construct() { $item = $this->itemResolver(); $imageThumbNailsPath = []; $imagePreviewPath = []; foreach(iterator_to_array($item,true) as $field){ $thumbNailsPath = sprintf('%s_thumbnail.jpg',$field); $previewsPath = sprintf('%s__preview.jpg',$field); } var_dump($imagePreviewPath); var_dump($imageThumbNailsPath); } public function itemResolver(): \Generator { // $stmt = mysqli_query($db_connect, "select pk_i_id from oc_t_item_resource ORDER by pk_i_id desc"); // $records = mysqli_fetch_all($stmt); $records = [ 0 => [0 => '4031'], 1 => [0 => '4030'], 2 => [0 => '4029'] ]; foreach($records as $record => $value){ yield $value; } } } var_dump(new Test());
based on fqQuX
Output for 7.2.0 - 7.3.0rc3
Warning: Use of undefined constant __DIR_ - assumed '__DIR_' (this will throw an Error in a future version of PHP) in /in/8knp2 on line 41 Notice: Array to string conversion in /in/8knp2 on line 12 Notice: Array to string conversion in /in/8knp2 on line 13 Notice: Array to string conversion in /in/8knp2 on line 12 Notice: Array to string conversion in /in/8knp2 on line 13 Notice: Array to string conversion in /in/8knp2 on line 12 Notice: Array to string conversion in /in/8knp2 on line 13 array(0) { } array(0) { } object(Test)#1 (0) { }
Output for 7.1.0 - 7.1.23
Notice: Use of undefined constant __DIR_ - assumed '__DIR_' in /in/8knp2 on line 41 Notice: Array to string conversion in /in/8knp2 on line 12 Notice: Array to string conversion in /in/8knp2 on line 13 Notice: Array to string conversion in /in/8knp2 on line 12 Notice: Array to string conversion in /in/8knp2 on line 13 Notice: Array to string conversion in /in/8knp2 on line 12 Notice: Array to string conversion in /in/8knp2 on line 13 array(0) { } array(0) { } object(Test)#1 (0) { }
Output for 5.6.38 - 7.0.28
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/8knp2 on line 4
Process exited with code 255.