语法错误,意外 'have' (T_STRING)

syntax error, unexpected 'have' (T_STRING)

如何解决此语法错误

unexpected 'have' (T_STRING) in /home/mithraa/public_html/svirtzone.com/projects/fandc/app/code/core/Mage/Newsletter/controllers/SubscriberController.php

public function unsubscribecusAction()
{
    $email = $this->getRequest()->getParam(’email’);
    $subsModel = Mage::getModel(’newsletter/subscriber’);
    $subscriber = $subsModel->loadByEmail($email);

    $id = (int) $subsModel->getId();
    $code = (string) $subsModel->getCode();
    if ($id && $code) {
        $session = Mage::getSingleton(’core/session’);
        try {
               Mage::getModel(’newsletter/subscriber’)->load($id)->setCheckCode($code)->unsubscribe();
               $session->addSuccess($this->__(’You have been unsubscribed.’));
        }
        catch (Mage_Core_Exception $e) {
            $session->addException($e, $e->getMessage());
        }
        catch (Exception $e) {
            $session->addException($e, $this->__(’There was a problem with the un-subscription.’));
        }
     }
     $this->_redirectReferer();
  } 

您使用了错误的引号字符来声明字符串:

正确:

'hello', "hello"

错误:

’hello’

将(引号) 更改为 '

    public function unsubscribecusAction()
    {
      $email = $this->getRequest()->getParam('email');
      $subsModel = Mage::getModel('newsletter/subscriber');
      $subscriber = $subsModel->loadByEmail($email);

      $id = (int) $subsModel->getId();
      $code = (string) $subsModel->getCode();
        if ($id && $code) {
       $session = Mage::getSingleton('core/session');
        try {
        Mage::getModel('newsletter/subscriber')->load($id)->setCheckCode($code)->unsubscribe();
        $session->addSuccess($this->__('You have been unsubscribed.'));
        }
        catch (Mage_Core_Exception $e) {
              $session->addException($e, $e->getMessage());
        }
            catch (Exception $e) {
                 $session->addException($e, $this->__('There was a problem with the un-subscription.'));
            }
        }
        $this->_redirectReferer();
    }

在您的代码中,您使用 tiled sign 符号而不是在代码中的任何地方使用单个 '"。像

’email’ 替换为 'email'"email"

我怀疑问题出在 ' 字符之间。看看这是否有效;

public function unsubscribecusAction() {
    $email = $this->getRequest()->getParam('email');
    $subsModel = Mage::getModel('newsletter/subscriber');
    $subscriber = $subsModel->loadByEmail($email);

    $id = (int) $subsModel->getId();
    $code = (string) $subsModel->getCode();
    if ($id && $code) {
        $session = Mage::getSingleton('core/session');
        try {
            Mage::getModel('newsletter/subscriber')->load($id)->setCheckCode($code)->unsubscribe();
            $session->addSuccess($this->__('You have been unsubscribed.'));
        } catch (Mage_Core_Exception $e) {
            $session->addException($e, $e->getMessage());
        } catch (Exception $e) {
            $session->addException($e, $this->__('There was a problem with the un-subscription.'));
        }
    }
    $this->_redirectReferer();
}