如何解决此语法错误,
意外'有' (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();
}
答案 0 :(得分:1)
使用错误的引号字符来声明字符串:
<强>正确:强>
'hello', "hello"
<强>错误:强>
’hello’
答案 1 :(得分:0)
将(引号)’
更改为'
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();
}
答案 2 :(得分:0)
在您的代码中,您使用tiled sign
符号代替在代码中的任何位置使用单'
或"
。像是
’email’
替换为'email'
或"email"
答案 3 :(得分:0)
我怀疑问题是’
和'
字符之间的区别。看看这是否有效;
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();
}