Skip to content
Advertisement

PHP Short Open Tag prints “1 “

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 ?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement