【发布时间】:2011-06-16 09:52:55
【问题描述】:
我把头撞到了墙上……我正在制作一个简单的 joomla 模块,在 helper.php 中我无法分配从表单发布的值。
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
class modReservationHelper {
public $name;
public $email;
public $message;
public $comment;
protected function __construct() {
$this->name = $_POST['fullname'];
$this->email = $_POST['email'];
$this->message = $_POST['message'];
$this->comment = $_POST['comment'];
}
function validateForm() {
echo $this->name; //The output is always 0
echo $this->email+"</br>";//The output is always 0
echo $this->message;//The output is always 0
//When I try
echo $_POST['comment']; // Is correct
}
}
?>
我也试过不使用具有相同零效果的构造函数:(
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
class modReservationHelper {
public $name;
public $email;
public $message;
public $comment;
function getValues() {
$this->name = $_POST['fullname'];
$this->email = $_POST['email'];
$this->message = $_POST['message'];
$this->comment = $_POST['comment'];
}
function validateForm() {
modReservationHelper::getValues;
echo $this->name; //The output is always 0
echo $this->email+"</br>";//The output is always 0
echo $this->message;//The output is always 0
//When I try
echo $_POST['comment']; // Is correct
}
}
?>
整个过程从“mod_wreservation.php”调用我调用modReservationHelper::validateForm();
【问题讨论】:
-
你是如何调用类 modReservationHelper 的函数的?