K
K
KRHD2015-11-03 11:18:13
PHP
KRHD, 2015-11-03 11:18:13

What is the problem with (file_get_contents)?

There is this code:

$info = file_get_contents("http://site.ru/check/check.php?domain=".$_SERVER['SERVER_NAME']);

It outputs 1 or 0
but the function
if($info == '0')
{
  exit('Лицензия не активна!');
}

for some reason does not work :(
because of what it can be?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Melkij, 2015-11-06
@KRHD

Good idea from Alexey Ukolov to duplicate the comment from the discussion as a full-fledged answer.
var_dump($info) displayed string(4) "0" to the author.
Here, special attention is not on the displayed "0", but on the number in brackets, which says that this line has 4 bytes. Not one, as would be the case in most encodings for the string "0".
The most obvious is that a BOM tag arrives in the server response. Just 3 bytes of the BOM, then the character 0 byte, that's 4 bytes in the response. But there may be something else - look at the server response with a hexdump. (alternatively, write the answer to a file and look at this file with a hexdump).

O
Optimus, 2015-11-03
Pyan @marrk2

'SERVER_NAME'
Name of the host where the current script is running. If the script is running on a virtual host, this will contain the name defined for that virtual host.

You always have the name of your site in the domain, i.e.
I didn't really understand the logic of your script, but it seems to me that this is not normal

D
Dmitry, 2015-11-03
@mytmid

if( empty ($info) )
{
  exit('Лицензия не активна!');
}

php.net/manual/en/function.empty.php#refsect1-func...

I
Ilya Beloborodov, 2015-11-03
@kowap

Try like this:

$info = file_get_contents("http://site.ru/check/check.php?domain=".$_SERVER['SERVER_NAME']);
if(intval($info)==0){

}else{

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question