Cases where php's short tags should be avoided

David Carr

Development

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');?>

 

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Fathom Analytics $10 discount on your first invoice using this link

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.