Black Friday sale is now on! 50% off Laravel: The Modular Way. Learn more

Cases where php's short tags should be avoided

David Carr


    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:


    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 Book by David Carr

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

    Subscribe to my newsletter

    Subscribe and get my books and product announcements.

    © 2009 - 2022 DC Blog. All code MIT license. All rights reserved.