You are here: Re: Checking PHP version for compatibility? « PHP Programming Language « IT news, forums, messages
Re: Checking PHP version for compatibility?

Posted by Chris Hope on 09/19/06 00:13

rustysmith@bellsouth.net wrote:

> Anyone know how to check the PHP version that a current file is
> running on? This would be helpful in the instance where you are trying
> to make a package that can be distributed publicly for use in a
> variety
> of configurations. This code should(?) work:
>
> $ver=PHP_VERSION;
> if(ereg('^[1-4]',$ver))
> $post_ids=array_flip(&$post_ids); // Old syntax
> else
> $post_ids=array_flip($post_ids); // PHP 5+ syntax
>
> but it still throws the error:
>
> Warning: Call-time pass-by-reference has been deprecated - argument
> passed by value; If you would like to pass it by reference, modify the
> declaration of array_flip(). If you would like to enable call-time
> pass-by-reference, you can set allow_call_time_pass_reference to true
> in your INI file. However, future versions may not support this any
> longer.
>
> When executed in PHP 5.+
>
> Thanks in advance for any ideas how to make this work?

I don't get the error when running either of your calls using PHP 5.1.2

As far as testing for the version, why not just do it like this instead
of using a regular expression:

if(PHP_VERSION >= 5) {
... php 5 code here ...
}
else {
... earlier versions code here ...
}

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация