Php include fingerprints 1

i encode the following

<?php 
if ($id = mysql_real_escape_string(@$_GET['pid']) 
    && $uid = mysql_real_escape_string(@$_GET['file']))
       echo include "foo.php"; 
    else 
       echo include "bar.php"; 
?>

When I use the include function in combination with a function that is intended to be output to a page (for example, or echo include "foo.php"), it returns include, but with "1" after the content that was included.

+5
source share
9 answers
echo include "foo.php"

it should be

include 'foo.php';
+19
source

Note that this can also happen when using include without echo:

<?= include 'foo.php'; ?>

It will also display a return value of 1 when used inside a script. To get rid of this, you need to remove the "=" sign in the instructions like this:

<? include 'foo.php'; ?>

PHP will now print the contents of the file with no return value.

+6
source

Okey, ; .

include . , .. , include . , ; return included.

, :

<?php return array
    (
        'some',
        'php'
        'based'
        'configuration',
        'file'

    ); # config

$config = include 'example-config-above.php'; , $config.

, return, 1.

Gotcha

, include 'example-config-above.php'; , , include, , , !

, , , , return , 1 , , - PEAR , , , - :

// on a lot of server setups this will load a random pear class
include 'system.php' 

, 1 ( ) , .

, :

include __DIR__.'/system.php' 
+3

=

==

php-

+1

.txt xxx

 echo include("file.txt");

, xxx1

"1" - include, . , .

  echo print "hello";

, hello1

, ; "1" , .

echo echo "hello";
print echo "hello";

. , undefined.

echo  echo "hello";           print echo "hello";
(1st) (2nd)                     

"" undefined. "" "" hello undefined ( ).

:

if((print "hello")==1)         
  echo "hey!";

 output: hellohey!    ('echo' in the 2nd line can be a print, it doesn't matter)

,

if((include ("file.txt"))==1)
echo "hey!";

output: xxxhey! 

,

if((echo "hello")==1)
echo "hey!";

output: an error

(print include) 1, "echo" (undefined), .

+1

, include 1 . , , " - earl1", , " - ", include(), 1.

0

/etc/php 5/cli/php.ini :

short_open_tag = 1

0

... Codeigniter ( php-). . , / include, 1 , include (, ), , .

<?php include('file/path'); ?> // this works fine for me
<?= include('file/path'); ?> // this works fine but prints "1" on screen

, -

0
source

Look for char 1in the .php file and circle your ass.

-2
source

All Articles