If condition for PHP Version ignore new code

旧时模样 提交于 2019-12-06 03:48:22

You could include different scripts based on version, then the script with syntax that isn't valid in 5.2 would never be included for that version.

if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
     include("script53.php");
} else {
     include("script52.php");
}

Instead of the above code and calling two different functions, I suggest creating the PHP 5.3 functions you need if they don't exist. That way you only have to remember one function name instead of two.

if (!function_exists('example_func')) {
   function example_func($str,$str2) {
      return $str.$str2; 
   }
}

example_func('abc','def');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!