Reputation: 13
I was trying to do an 'search for updates page' with php with this code:
<?php
$update = file_get_contents('https://raw.githubusercontent.com/esteves25566/gestordebiblioteca/master/updater');
if ($update == "build001"){
}else{
echo "<p style= \"color:red\">Existe um novo update! A nova build é a $update</p>";
}
?>
But when the site output is build001, the if sentence go to read it as false, printing "Existe um novo update! A nova build é a build001" I already try everyting! Thanks for the help!!!
Upvotes: 1
Views: 49
Reputation: 13
Thanks for the both questions!!! It has been resolved. Both questions work but i prefer this because i think is more easy!!
<?php
$update = file_get_contents('https://raw.githubusercontent.com/esteves25566/gestordebiblioteca/master/updater');
if ($update == "build001\n"){
echo 'gotit';
}else{
echo "<p style= \"color:red\">Existe um novo update! A nova build é a $update</p>";
}
?>
Thanks a lot!
Upvotes: 0
Reputation: 94682
There is an unprintable character at the end of build001, its a newline character by the looks of it.
Try this test
<?php
$update = file_get_contents('https://raw.githubusercontent.com/esteves25566/gestordebiblioteca/master/updater');
if ($update == "build001\n"){
echo 'gotit';
}else{
echo "<p style= \"color:red\">Existe um novo update! A nova build é a $update</p>";
}
Upvotes: 1
Reputation: 691
Not sure if i understand you here, but
$update = file_get_contents('https://raw.githubusercontent.com/esteves25566/gestordebiblioteca/master/updater');
if ( trim( $update ) <> 'build001') {
echo '<p style="color:red">Existe um novo update! A nova build é a ' . $update . '</p>';
exit();
}
Upvotes: 0