oleg_sm
(oleg_sm)
1
Hello.
I have problem with yii2.
The project has a controller:
\frontend\controllers\ArticleController
The controller has a method:
public function getCategoryName($id){
// ...
}
Some widget refers to the controller:
$category = ($in->type_id==1) ? \frontend\controllers\ArticleController::getCategoryName($post->category) : 'Полезные статьи';
It works on the server!
Doesn’t work on my localhost!
What’s the matter?
Why is there no error on the server, but there is an error on my localhost?
I would be grateful for your answer.
Bizley
(Bizley)
2
Different environment configurations, maybe different PHP versions as well. Basically you should not call non-static methods statically ever.
Check PHP Versions on Localhost and Server. PHP 8.0 and above will throw exception about this.
https://www.php.net/manual/en/language.oop5.static.php
oleg_sm
(oleg_sm)
4
Thaks you!
The problem is in the environment.
Localhost has php version 5.6.40
There is a mistake here.
Server has php version 5.6.36
It works.
I started up the old localhost. It has php version 5.6.32
It works too.
This is not my code. But I have to fix it.
The method was called incorrectly!
Bizley
(Bizley)
5
And please update your PHP. 5.6 is ancient.