0

Hy,

I'm getting an issue when I'm doing a file on some .php files on apache2 Vhost. Here is the problem:

# file *.php
file1.php:    PHP script, UTF-8 Unicode text, with very long lines
file2.php:    PHP script, UTF-8 Unicode text, with very long lines
file3.php:    HTML document, UTF-8 Unicode text, with very long lines

Any ideas on why the system (RHEL) doesn't see file3.php as PHP script ?

# head file3.php 
<?
include("./some/files.php");

$var="";

$var = "select var, var from vars order by 2";
$var = var($var,$var);
while ($var = @var($var))
{ var($var) ;
  $var .= "\"".$var."\"," ;

I've changed <? to <?php but nothing has changed.

php -v
PHP 5.4.16 (cli)
2
  • Is it only the file output that bothers you? If this is not your actual issue, you should post a new question with a detailed explanation of your problem. Sep 6, 2016 at 8:21
  • Yes it's just the output of file command that I don't understand.
    – corentin
    Sep 6, 2016 at 8:56

2 Answers 2

2

The file utility uses different heuristics to determine the file type. It may be the case that file3.php has more HTML-tags than the other two.

However, the output of the file utility does not influence your system's operation (unless you are parsing the output, of course). In particular, it is not "your system (RHEL)" that treats this file as HTML. If it is a valid PHP file, php will execute the script as it should - independent of what file says. (Try php -l file3.php for a syntax check.)

-1

Your server is not running your file as php script because you are using short tags in your php script i.e <? //php code ?> and in some php installation the short tags are default disabled.

So simply replace <? ?> tags with <?php ?> or enable the short tags from php configuration.

1
  • Quoting the Question, "I've changed <? to <?php but nothing has changed"
    – Jeff Schaller
    Sep 30, 2016 at 16:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .