如何简单地即时工作? 我对我创建/证实的所有类别都采取了同样的方法,但这只是给我留下这种错误的唯一方法。
Fatal error: Call to a member function validate_fname_and_lname() on a non-object in /homepages/......../Validate.php on line 23
我的守则如下:
//Class Validate
<?php
require_once RegExp.php ;
$myRegExp = new RegExp();
class Validate
{
//Sends each entry to corresponding RegExp function with appropriate regular expression
function validate_form($un, $fname)
{
$err_counter = 0;
if(!$this->myRegExp->validate_fname_and_lname($fname))
{
$error_identifier .= firstName+ ;
++$err_counter;
}
}
}
//Class RegExp
<?php
class RegExp
{
function validate_fname_and_lname($flname)
{
return preg_match("/[a-zA-Z ]{2,}/", $flname);
}
}