开发者

`new` and `use` keyword paths

Im on a host company that uses php 5.2 , some of the libraries i use are written in 5.3 an开发者_高级运维d there are certain incompatibilities between the code.

First of all what is the alternative to :

use \folder1\folder2\class_file;

Secondly what is the alternative to :

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

Thanks in advance.


Namespaces are not backward compatible with PHP < 5.3

You're going to have to:

  • 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


I'd say it depends on the amount of PHP 5.3 code and if your project is worth more than 5 Bucks per month to you.

My main suggestion is: Change your hosting provider.

If they don't offer PHP 5.3, a PHP Version released at the 30th of June 2009 (thats two years!) you are better of just not wasting your time trying to get your project to run there.

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

Just don't waste your time creating an 'old' application because of some hosting company.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜