PHP脚本版本检查/通知

PHL*_*LAK 7 php

如何根据在线文件检查我的脚本版本,看看它是否是最新版本?

为了澄清,我说的是我写的脚本,而不是PHP的版本.我想为最终用户提供一种方法来告诉我何时更新了脚本.

Ste*_*rig 15

要指定第二个(更简单)解决方案phjr:

version.txt在您自己的公共服务器上有一个文件,并在您部署的项目/脚本中包含以下函数:

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');
}
Run Code Online (Sandbox Code Playgroud)

version.txt 应该只包含最新的版本号,例如:

1.0.2
Run Code Online (Sandbox Code Playgroud)