如果条件从一个类函数转到另一个类函数,我试图获取一个varibale的值。
请你告诉我我该怎么做(我是PHP新手。)
代码:
class ErrorList{
static function getErrorsSince($delay, $criteria = NULL) {
global $appsFeXref, $table_error,$table_error_dis, $table_occurrence, $table_status, $table_fe_parameters, $debugMode;
if ($criteria->isValid()){
$var1 = '123';
}
}
Class Error{
function initFromDb($initDetails = false) {
global $appsFeXref, $table_error, $table_status, $table_fe_parameters, $table_error_dis;
$details = ($initDetails)? ", s.last_time, s.last_time_origin, s.last_time_machine, s.last_time_text, s.last_time_peak, ed.comment ":"";
$test = $var1;
echo "$test";
}
在这里,您可以看到我需要从$var1
班级到ErrorList
班级的Error
变量值。
提前致谢。
此致 Tejesh.B
答案 0 :(得分:0)
<?php
class ErrorList{
static function getErrorsSince($delay, $criteria = NULL) {
global $appsFeXref, $table_error,$table_error_dis, $table_occurrence, $table_status, $table_fe_parameters, $debugMode;
if ($criteria->isValid()){
$var1 = '123';
return $var1;
}
}
}
class Error{
function initFromDb($initDetails = false) {
global $appsFeXref, $table_error, $table_status, $table_fe_parameters, $table_error_dis;
$details = ($initDetails)? ", s.last_time, s.last_time_origin, s.last_time_machine, s.last_time_text, s.last_time_peak, ed.comment ":"";
$call_class = new ErrorList();
$get_val = $call_class->getErrorsSince();
$test = $get_val;
echo $test;
}
}
?>