Backward version compatibility in PHP web application

Posted by Stanislav Furman  on February 17, 2014

If you develop a PHP web application which may be used on a web server with older PHP version, you can run into a situation when some of the PHP functions in your application won't work at all, or won't work as expected.

In fact, you can handle those situations if you want to. However, it can make you application code not as nice as you want and a little heavier.

Here is an example of how you could handle such a situation:

<?php
if (version_compare(phpversion(), '5.3.0', '<')) {
	$controllerName=get_class($this);
} else {
	$controllerName=get_called_class();
}

Leave your comment

Fields with * are required.

* When you submit a comment, you agree with Terms and Conditions of Use.