ukweb Posted February 26, 2008 Share Posted February 26, 2008 Hi there. I have a communally accessed include file which is used by a number of websites, operating from many different servers, no problems there (I'm sure there are those who would disagree!!!) Problem comes with the current site I'm working on, the client specifically stated that the site is to exist on the server it is on, and that server runs only PHP version 4. 99.9% of my code in the include file works with version 4, apart from 1 line... that line has the function date_default_timezone_set(). This only works with version 5 as far as I am aware. So here's the solution... if (php version >= 5) { date_default_timezone_set(); } Basically if the php version isnt 5 or greater, dont run the date_default_timezone_set function. but is there a server variable which contains the php version??? I cant find one? anyone else got any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 26, 2008 Share Posted February 26, 2008 From the php manual - Predefined Constants Core Predefined Constants These constants are defined by the PHP core. This includes PHP, the Zend engine, and SAPI modules. PHP_VERSION (string) Quote Link to comment Share on other sites More sharing options...
Orio Posted February 26, 2008 Share Posted February 26, 2008 <?php $phpver = phpversion(); if($phpver[0] >= 5) //use PHP5 functions ?> Orio. Quote Link to comment Share on other sites More sharing options...
aschk Posted February 26, 2008 Share Posted February 26, 2008 The error you are getting should only be at warning level if you don't use date_default_timezone_set(); and thus it'll default, so in fact you could leave the function call out. Just an alternate option I guess. Quote Link to comment Share on other sites More sharing options...
ukweb Posted February 26, 2008 Author Share Posted February 26, 2008 Works a treat now! thanks for your help everyone! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.