Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-23-2011, 03:55 PM PHP Version Compare
Junior Talker

Posts: 1
Trades: 0
I was hoping someone could take a couple minutes to post some code for me.

I need to compare two text files versions, one on the local server and one on a remote server.

Here would be the locations of both:

Local: /lib/version.txt
Remote: hxxp://mysite.com/version.txt

Basically, basically in /lib/version.txt I would just enter "1.1.0" and then if I updated the remote file's text to "1.2.0" then there would be a message showing up in people's control panel that said something like:

Quote:
Click here! There is a new update!
ChaseZZZ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-23-2011, 05:43 PM Re: PHP Version Compare
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
version_compare: http://www.php.net/manual/en/functio...on-compare.php
and file_get_contents: http://www.php.net/manual/en/functio...t-contents.php

PHP Code:
$local_file '/lib/version.txt';
$remote_file 'http://mysite.com/version.txt';

$current_version file_get_contents($local_file);
$latest_version file_get_contents($remote_file);

if(
version_compare($current_version$latest_version) === -1)
{
     
//newer version available

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to PHP Version Compare
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09963 seconds with 12 queries