Cases where php's short tags should be avoided

David Carr

1 min read - 8th Feb, 2017

When designing my email layout files I like to break them down into parts and include them together as needed using includes. I've stumbled across a display issue when using a short tag include:

<?=include('Layouts/Header.php');?>

This caused a 1 to be displayed where the file is being included. Which when you think about it kind of makes sense since short tags are meant for simple variable output and not a chunk of HTML. So when run they are essentially booleans (true) to avoid this I stopped using short hand:

<?php include('Layouts/Header.php');?>

 

0 comments
Add a comment

Copyright © 2024 DC Blog - All rights reserved.