Php 5.2 new and use the problem with keywords

Im in a host company that uses php 5.2, some of the libraries that I use are written in 5.3, and there are certain incompatibilities between the code.

First of all, what is an alternative:

use \folder1\folder2\class_file; 

Secondly, what is an alternative:

 $sample = new \folder1\folder2\class_file($arg1, arg2); 

Thanks in advance.

+7
source share
2 answers

Namespaces are not backward compatible with PHP <5.3

You need:

  • remove all cases of namespace and use statements
  • rename your classes from class_file to folder1_folder2_class_file (or similar)
  • use $sample = new folder1_folder2_class_file($arg1, $arg2); to create an instance
+13
source

I would say that it depends on the amount of PHP 5.3 code, and if your project costs you more than $ 5 a month.

My main suggestion: Change your hosting provider.

If they do not offer PHP 5.3, the version of PHP released on June 30, 2009 (that is, two years!), You better not just waste time getting your project to run there.

5.3 is mature enough to be used in production, and 5.2 has completed its life cycle ( end of support for php 5.2 branch ).

Just do not waste time creating an "old" application because of some kind of hosting company.

+7
source

All Articles