各位,我在网页中呈现/显示表单时遇到了一些问题。好吧,它在我的本地服务器上运行良好,但一旦我在远程服务器上使用相同的代码,网页显示正常,但表单丢失。
本地主机:
操作系统:Win 7
PHP: 5.3.8
Apache :2.2.21
Zend:1.11.3
远程服务器:
操作系统:Linux CentOS 5.5版
PHP:5.3.8
Apache :2.2.3
Zend:1.11.3
FeedbackForm.php
class forms_FeedbackForm extends Zend_Form {
public function init() {
$this->setAction('')->setMethod('post')->setName('feedbackForm');
$feedback = new Zend_Form_Element_Textarea('feedback');
$submit = new Zend_Form_Element_Button('submitButton');
$this->addElement($feedback)->addElement($submit);
} }
IndexController.php
class IndexController extends Zend_Controller_Action {
public function indexAction() {
$form = new forms_FeedbackForm();
$this->view->form = $form;
} }
index.phtml
echo $this->form;
但是,如果我用 print_r($this->form) 替换 echo 语句,我会看到两个服务器的对象详细信息。
最佳答案
为您的类(class)使用大写字母:Forms_FeedbackForm 而不是 forms_FeedbackForm。自动加载器在 Linux 上找不到它。
通常,当 Linux 和 Windows 服务器之间出现此类问题时,这是一个严重的问题。 Linux 区分大小写,Windows 则不然。
关于php - Zend_Form 不渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7975601/