Reputation: 672
When i write php code with html using php short open tag, it prints 1 every time.
<?= include_once 'includes/footer.php';?>
Why it's happening ?
Upvotes: 1
Views: 158
Reputation: 919
Just remove the =
sign and try. In short tags =
used for echo and since you're including the file without any problem it returns 1 and it will be echoed back.
Upvotes: 1
Reputation: 1091
Because include_once return TRUE, so if you print it it will display "1"
Upvotes: 1
Reputation: 76
Php Short Tag is used to echo the variable not for including the file
<?= ?> (echo short tags)
See this http://php.net/manual/en/language.basic-syntax.phptags.php
Upvotes: 2
Reputation: 4975
Because it returns true. You need to use include_once
without the short open tag, so like this:
<?php include_once 'includes/footer.php';?>
When you write an open short tag, like this;
<?= include_once 'includes/footer.php';?>
You actually write this:
<?php echo include_once 'includes/footer.php';?>
Which results in "1" on your screen.
Upvotes: 5