3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Find id's of previous and next product in featured module $products = $this->model_catalog_product->getProducts(); $product_id = (int)$this->request->get['product_id']; $key = array_search($product_id, array_column($products, 'product_id')); $products = array_values($products); if ($key === 0) { $temp = end($products); $data['prev_product_id'] = $temp['product_id']; } else { $data['prev_product_id'] = $products[$key - 1]['product_id']; } if ($key === count($products) - 1) { $temp = reset($products); $data['next_product_id'] = $temp['product_id']; } else { $data['next_product_id'] = $products[$key + 1]['product_id']; } // Find last image of previous product $prev_product_images = $this->model_catalog_product->getProductImages($data['prev_product_id']); $prev_product_last_image = end($prev_product_images); if ($prev_product_last_image) { $data['prev_product_image'] = $this->model_tool_image->placeholder_image($prev_product_last_image['image']); } else { $data['prev_product_image'] = ''; } // Find first image of next product $next_product_images = $this->model_catalog_product->getProductImages($data['next_product_id']); $next_product_first_image = current($next_product_images); if ($next_product_first_image) { $data['next_product_image'] = $this->model_tool_image->placeholder_image($next_product_first_image['image']); } else { $data['next_product_image'] = ''; }
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/NUvf3:3 Stack trace: #0 {main} thrown in /in/NUvf3 on line 3
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Using $this when not in object context in /in/NUvf3 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Call to a member function on a non-object in /in/NUvf3 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to a member function on a non-object in /in/NUvf3 on line 3