Markus Freundorfer
Markus Freundorfer

Reputation: 123

require_once writes "1" to source code

I'm new to PHP and trying to include a file in another with the following code:

<?= require_once ('../template/header.phtml')?>

The inclusion works, but it also adds a "1" to the source code. Same happens if I use include() include_once() or require(). Got no results searching the web as well.

Upvotes: 1

Views: 635

Answers (2)

Schlaus
Schlaus

Reputation: 19212

You're using <?= instead of <?php to start your script. <?= is used to print something to the screen, which in this case is the return value from require_once ('../template/header.phtml'), which most likely is TRUE ie. 1. Change the opening tag and your problem should go away.

The correct place to use <?= is when you just want to print a variable or a function's return value in the middle of html, like so:

<div>
    <?=$some_variable?>
</div>

Upvotes: 3

bladerz
bladerz

Reputation: 433

You should use <?php require_once ('../template/header.phtml')?>

Upvotes: 1

Related Questions