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){ $imageThumbNailsPath[] = $thumbNailsPath = sprintf('%s_thumbnail.jpg',$field[0]); $imagePreviewPath[] = $previewsPath = sprintf('%s__preview.jpg',$field[0]); } 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 eQImf
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/tP5iH on line 41 array(3) { [0]=> string(17) "4031__preview.jpg" [1]=> string(17) "4030__preview.jpg" [2]=> string(17) "4029__preview.jpg" } array(3) { [0]=> string(18) "4031_thumbnail.jpg" [1]=> string(18) "4030_thumbnail.jpg" [2]=> string(18) "4029_thumbnail.jpg" } object(Test)#1 (0) { }
Output for 7.1.0 - 7.1.23
Notice: Use of undefined constant __DIR_ - assumed '__DIR_' in /in/tP5iH on line 41 array(3) { [0]=> string(17) "4031__preview.jpg" [1]=> string(17) "4030__preview.jpg" [2]=> string(17) "4029__preview.jpg" } array(3) { [0]=> string(18) "4031_thumbnail.jpg" [1]=> string(18) "4030_thumbnail.jpg" [2]=> string(18) "4029_thumbnail.jpg" } 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/tP5iH on line 4
Process exited with code 255.