version update script for a script
Marlboroman213’s Question:
I’m going to try making this easy to understand and hope it makes sense.
I have a PHP script / template and I want the end user to be able to know when I updated something, (eg. template change or a bugfix) and they can click a link to download the updated version from a remote host. I tried the scripts posted on
PHP – How to check a script version and I sorta got this script working:
<?php define('REMOTE_VERSION', http://mysite.com/_client/client_name/update/version_check.txt');
define('VERSION', '2.0.1');
$script = file_get_contents(REMOTE_VERSION);
$version = VERSION;
if($version == $script) {
echo "<div class=success>
<p>You have the latest version!</p>
</div>";
} else {
echo "<div class=error>
<p>There is a update available!</p>
</div>";
}?>
Well sort of… The .txt file on my remote server just has 2.0.1. Since they are the same version (both 2.0.1), it should read “You have the latest version!” In this case it says “There is a update available!” no matter what number I put in.
define('VERSION', '2.0.1'); //in php above
2.0.5 //in .txt file on remote server
Says same things as it should because on the remote server is showing a new update (eg. 2.0.5). Can anyone tell me what I am doing wrong?
This might be a typo, but there is an error at your constant definition.
define('REMOTE_VERSION', http://mysite.com/_client/client_name/update/version_check.txt');
// ^ Missing quote