PHP Script Version Checking/Notification

后端 未结 4 1043
情歌与酒
情歌与酒 2021-02-04 17:08

How can I check the version of my script against an online file to see if it\'s the latest version?

For clarification, I\'m talking about a script I wrote, not the v

4条回答
  •  梦如初夏
    2021-02-04 17:31

    To specify the second (more simple) solution phjr proposed:

    Have a file version.txt on your own public server and include the following function into your deployed project/script:

    define('REMOTE_VERSION', 'http://your.public.server/version.txt');
    
    // this is the version of the deployed script
    define('VERSION', '1.0.1');
    
    function isUpToDate()
    {
        $remoteVersion=trim(file_get_contents(REMOTE_VERSION));
        return version_compare(VERSION, $remoteVersion, 'ge');
    }
    

    version.txt should just contain the most recent version number, e.g.:

    1.0.2
    

提交回复
热议问题