In general, there are 2 servers, on one everything works and on the other peaks ... well, in general, the essence of the problem:

On the local host (I run it through OpenServer, I did not touch the settings of the puff, puff 5.3, Yii 1.1.17) I have a file Locale.php in which the class is declared

class Locale extends CLocale. 

In this class there is a static getInstance() method to which I refer from the method of another class NFormatter::getLocale()

 public static function getLocale() { CLocale::$dataPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'; $locale = 'ru_ua';//Yii::app()->language; var_dump(Locale::getInstance($locale)); } 

On the local machine, the getInstance method is visible and returns the data I need, and on the hosting an error accesses the nonexistent method. For debug created object of class, made dump

 $loc = new Locale($locale); get_class($loc) var_dump(get_object_vars($loc)); var_dump(method_exists($loc,'getInstance')); 

As soon as I upload to the hosting, the dump is empty and method_exists returns false, although get_class($loc) shows the class Locale. That is, the class is visible here and there, but on the hosting for some reason there is no access to its methods. I suspect that this is all the same server settings, which is very strange.

  • And what is installed at the hoster? And the access rights and paths are correctly specified? var_dump(get_class_methods(get_class($loc))); ? - E_p
  • The access rights were rechecked several times since it was the first version, but with the permissions everything is fine. The paths are all correct, otherwise the class itself would not be visible, but the class is visible. Dump on LAN returned array(58) { [0]=> string(11) "__construct" [1]=> string(4) "init" [2]=> string(15) "setConfigNumber" [3]=> string(11) "getInstance" + CLocale parent class methods, on the hosting the same dump returned only CLocale parent class methods. - qwezert
  • This is how it will be better seen - (above ==== hosting, under lokalka) pastebin.com/tYSARBg6 - qwezert

1 answer 1

I found the reason. Thanks to E_p for the help to display all the methods, I saw that the methods that were returned by the dump are not mine, it’s useful to google and it turned out that the Locale class already exists in php. It is strange that Puff did not write anything about the fact that I was trying to announce an already existing class. Rename the class to my friend and it all worked.

Moral: Call the classes with prefixes, otherwise it will be an ass.

  • In yii, most likely an auto download. And if the class is found to load nothing. Well, you need to go to the current version of PHP and use the namespace - E_p