3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.3.0alpha1 - 7.3.0rc4
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.2.6
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.6.28
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.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.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.