There is a file with a class and the Profile.php function:
<?php class News { public static function getNewsList() { $api = "123123123"; return $api; $logmein = "xyz"; //Функция большая, это её начало.
There is a file that includes the code above:
<?php include_once ROOT. '/models/Profile.php'; class ProfileController { public function actionIndex() { $api = News::getNewsList(); echo $api; // Выводит на экран APi //Когда я ещё раз вызываю что-то: $logmein = News::getNewsList(); echo $logmein //Notice: Constant DB already defined in return true; }
The function is connected, api is even displayed on the screen, but how can I derive other variables from this file? If you re-call a function, you crash a lot of errors, saying that what I am calling is already in use. How correctly can the other variables be derived?
getNewsList
returns only$api
. You can return an array:return array("api" => $api, "logmein" => $logmein);
, and inactionIndex
to get access to values by indexes. 2 -Constant DB already defined in
what else is a DB? Probably a repeated call to thegetNewsList
method leads to a redefinition of the constant. - UserNamelogmein
set to null. It is necessary to localize the problem, that is, to check the results of calls to functions that set the values. - UserName