SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check php version

    Hi Guys,

    I have a very simple problem, I think...

    I am trying to check PHP version on a server with the following code. Let's say the server has version 5.2.11 installed, which is actually a newer version than 5.2.5, the error will say trigger. I have tried checking the version number without quotes as well but then get a syntax error. Any ideas?

    PHP Code:
    if(phpversion() < "5.2.5"){
        
    $Error['error'][] = "You currently have PHP ".phpversion()." installed.  Domain Trader v2.5 requires PHP 5.2.5 or later to be installed on your server.";


  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,805
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    From the user notes on the manual page:
    PHP Code:
    <?php
        
    if (strnatcmp(phpversion(),'5.2.10') >= 0)
        {
            
    # equal or newer
        
    }
        else
        {
            
    # not sufficiant
        
    }
    ?>
    That might work
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    From the user notes on the manual page:
    PHP Code:
    <?php
        
    if (strnatcmp(phpversion(),'5.2.10') >= 0)
        {
            
    # equal or newer
        
    }
        else
        {
            
    # not sufficiant
        
    }
    ?>
    That might work
    Hi Spikez,

    This code will just check for version 5.2.10, will it not? How can I check if the version is lower than 5.2.5?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Location
    Brisbane, Australia
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (-=== version_compare(PHP_VERSION'5.2.5')) {
        
    $Error['error'][] = "You currently have PHP ".phpversion()." installed.  Domain Trader v2.5 requires PHP 5.2.5 or later to be installed on your server.";



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •