Freak "1" number appear after require and echo blanc file

129 views Asked by At

I have very freak problem :-)

Please, see this simple website: http://tests.vipserv.org/

There is... "1" number. But in code there is no any "1"...

I converted eol to Unix. No results. Also changed coding to UTF with/without boom.

"Website" is created from files: index.php:

<?php
class View {
    public static $TPL_VIEW = 'view.php';

    public static function renderView($template, $data = array()) {
        echo require $template;
    }

    public static function generateView($template, $data = array()) {
        return require $template;
    }
}

View::renderView(View::$TPL_VIEW, '');
?>

and view.php:

(blanc)

You can download files from:

http://ge.tt/4Td1TeI2/v/1

http://ge.tt/4Td1TeI2/v/0

Thanks, A.

2

There are 2 answers

1
jeroen On BEST ANSWER

You are echoing it out yourself. According to the manual:

Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1.

So instead of:

echo require $template;

You probably want:

require $template;

Assuming that your template is not supposed to actually return anything of course.

1
Ani On
echo require $template; 

require returns if include succeeded or not i.e. true or false or 1 or 0. so echo is displaying it.