很简单.我正试图从我的控制器中调用一个函数.事实上,该功能已定义.然而,当调用该函数时,我得到"PHP致命错误:调用未定义函数validate()..."
这是我的代码.有任何想法吗?谢谢.
<?php
class HomeController extends BaseController {
/**
* Controller for the index action of the home page. Displays the landing page.
*/
public function index()
{
return View::make('landing', array('success' => false));
}
/**
* Controller to handle processing the contact form and re-displaying the landing page
*/
public function processForm()
{
$form_array = array();
$errors = array();
foreach (array('email','fname','lname','message','newsletter') as $val)
{
if (isset($_POST[$val]))
$form_array[$val] = $_POST[$val];
else
$form_array[$val] = null;
}
$form_ok = validate();
if ($form_ok)
{
echo "GOOD!";
}
else
{
echo "BAD!";
}
}
/**
* Helper function for validating the form. Returns true if the form was
* submitted without errors.
*/
public function validate()
{
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11130 次 |
最近记录: |