Wednesday, December 3, 2014

Using include include_once print number 1

If in writing your code in php and you are using the include or include_once and the number 1 is printed also, it means that you are using the echo with the include or include_once statement.

So....

if you have

echo include 'foo.php' or echo include_once 'foo.php', remove the echo so it becomes
include 'foo.php' or include_once 'foo.php'

if you are using the short_open_tags, eg:

<?= include_once 'foo.php'?> or <?= include 'foo.php'?>, remove the echo, in this case its the '=' equal sign so it becomes:

<? include_once 'foo.php'?> or <? include 'foo.php'?>

No comments: