[英]php OOP - call static method from another class within class
I have the following class to another class in my main class. 我的主班有以下班级到另一个班级。
class Products
{
public function __get( $key ){
return trim(functions::mssql_escape_string_rev($this->fields[ $key ]));
}
}
This beings back error: Call to undefined method functions::mssql_escape_string_rev()
这个存在错误:
Call to undefined method functions::mssql_escape_string_rev()
Is there something wrong with my syntax or can this not be done? 我的语法有问题吗?还是无法解决?
Below is code used to autoload classes, this works for everything else so I know there is nothign wrong with the code. 下面是用于自动加载类的代码,该代码可用于其他所有内容,因此我知道代码没有什么错误。 It just doesnt seem to initiate within the class.
它似乎并没有在班级内启动。
// autoloader function called when we try to instantiate a class but haven't included the file
function __autoload($resource_name){
$resource_name = trim($resource_name);
try {
$filepath = CLASS_PATH."/class.".$resource_name.".inc.php";
if(@!include($filepath)){
throw new Exception('');
}
} catch(Exception $e) {
exit("Could not find the required file: ".$resource_name);
}
}
** * **** EDIT * **** Please ignore this, I made a stupid mistake and included the functions::mssql_escape_string_rev twice. ** * **** 编辑 * ****请忽略这一点,我犯了一个愚蠢的错误,并包含两次函数:: mssql_escape_string_rev。 Sorry for timewasting..
很抱歉浪费时间。
As the error says the problem is that functions::mssql_escape_string_rev()
is not defined. 如错误所示,问题在于
functions::mssql_escape_string_rev()
。
Since we can't see what you think is the definition we can not really help you. 由于我们看不到您认为的定义,因此我们无法真正为您提供帮助。
For me it looks like the call should be Functions::mysql_escape_string_rev()
with capital F
and mysql
. 对我来说,调用应该是带有大写
F
和mysql
Functions::mysql_escape_string_rev()
。
Update 更新
Calling static functions from another class works normally: http://codepad.org/wrfm5X7j 从另一个类调用静态函数正常工作: http : //codepad.org/wrfm5X7j
Maybe you are calling mysql_escape_string_rev before you included the functions class. 也许在包含函数类之前就在调用mysql_escape_string_rev。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.