I am trying to get access to a static variable from another class, but I keep getting an error (the one in the title) that says my variable is not being recognized.
Below is my Categorize class where the static variable, which is an array named $arr, is located:
class Categorize extends Controller{
public static $arr = array();
function run($xml){
global $FILE_ROOT, $STORAGE, $REQ_ID, $CMD_EXTRA, $LIB,
$BIN;
$numCategories = intval($xml->numCategories);
self::$arr;
/*self::$arr = array();*/
/*if(!pe($xml, "resourceList")) die(err("No resources found"));*/
for($i=0;$i < $numCategories; $i++){
$name = intval($xml->nameCat);
if($i=0){
$arr[0][0] = $name;
}else{
$arr[$i][0] = $name;
}
}
$j = 0;
while($j < $numCategories){
$numDoc = intval($xml->numDoc);
$k = 0;
foreach($xml->resourceList->resource as $res){
$arr[$j][$k] = $res;
$k++;
}
$j++;
}
$output = "Done!";
$response = "<parameters><requestType>categorize</requestType><requestID>". $REQ_ID . "</requestID><resourceList>". $output . "</resourceList></parameters>";
return $response;
}
}
Here is a class called Get_category where I am trying to access the static variable $arr from my the Categorize class:
class Get_category extends Controller{
function run($xml){
global $FILE_ROOT, $STORAGE, $REQ_ID, $CMD_EXTRA, $LIB,
$BIN;
include_once __DIR__.'/categorize.php';
$file = $xml->filename;
Categorize::$arr;
/*$arrlength = count($arr);*/
$arrlength = max(array_map('count', $arr));
$response = "<parameters>\n<requestID>" . $REQ_ID ."</requestID>\n<requestType>get_category</requestType>";
for($i = 0; $i < $arrlength; $i++){
$lengthcolumn = count($arr[$i]);
for($j = 0; $j < $lengthcolumn; $j++){
if($arr[$i][$j] == $file){
echo $arr[$i][$j];
$response .= "<resource><id>" . $arr[$i][$j] . "</id>";
$response .= "</resource>";
}
}
}
$response .= "</parameters>";
return $response;
}
}
I don't understand why my $arr variable is being unrecognized.