3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Album\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; use Album\Model\Album; use Album\Form\AlbumForm; class AlbumController extends AbstractActionController { protected $albumTable; public function indexAction() { return new ViewModel(array( 'albums' => $this->getAlbumTable()->fetchAll(), )); } public function addAction() { $form = new AlbumForm(); $form->get('submit')->setAttribute('value', 'Add'); $request = $this->getRequest(); if ($request->isPost()) { $album = new Album(); $form->setInputFilter($album->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $album->exchangeArray($form->getData()); $this->getAlbumTable()->saveAlbum($album); // Redirect to list of albums return $this->redirect()->toRoute('album'); } } return array('form' => $form); } public function editAction() { $id = (int)$this->params('id'); if (!$id) { return $this->redirect()->toRoute('album', array('action'=>'add')); } $album = $this->getAlbumTable()->getAlbum($id); $form = new AlbumForm(); $form->bind($album); $form->get('submit')->setAttribute('value', 'Edit'); $request = $this->getRequest(); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $this->getAlbumTable()->saveAlbum($album); // Redirect to list of albums return $this->redirect()->toRoute('album'); } } return array( 'id' => $id, 'form' => $form, ); } public function deleteAction() { $id = (int)$this->params('id'); if (!$id) { return $this->redirect()->toRoute('album'); } $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost()->get('del', 'No'); if ($del == 'Yes') { $id = (int)$request->getPost()->get('id'); $this->getAlbumTable()->deleteAlbum($id); } // Redirect to list of albums return $this->redirect()->toRoute('album'); } return array( 'id' => $id, 'album' => $this->getAlbumTable()->getAlbum($id) ); } public function getAlbumTable() { if (!$this->albumTable) { $sm = $this->getServiceLocator(); $this->albumTable = $sm->get('Album\Model\AlbumTable'); } return $this->albumTable; } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Class "Zend\Mvc\Controller\AbstractActionController" not found in /in/vnItD:10 Stack trace: #0 {main} thrown in /in/vnItD on line 10
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'Zend\Mvc\Controller\AbstractActionController' not found in /in/vnItD:10 Stack trace: #0 {main} thrown in /in/vnItD on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
Fatal error: Class 'Zend\Mvc\Controller\AbstractActionController' not found in /in/vnItD on line 10
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Fatal error: Class 'Zend\Mvc\Controller\AbstractActionController' not found in /in/vnItD on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/vnItD on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/vnItD on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/vnItD on line 3
Process exited with code 255.

preferences:
266.65 ms | 401 KiB | 425 Q