PHP  "explicit" echo feature

Posted on 2008-11-15
Last Modified: 2012-05-05
HTML code inside a .PHP file gets conveyed to the output stream without the need for echo statements.
This works nicely in while loop contexts (for instance), such that the php code  loop structure envelopes HTML code and no echo is needed.
 <? while ...  {   // begin loop  ?>
    HTML code
 <?    }// end loop  ?>

1. Where is this documented
2. Does this work in the context of functions too  (as opposed to the above being just inline mainline code?

Question by:willsherwood
    LVL 142

    Accepted Solution

    >1. Where is this documented
    in the docs, "first page", at least almost:

    >2. Does this work in the context of functions too
    LVL 34

    Assisted Solution

    by:Beverley Portlock
    Well, you could start here or

    "Does this work in the context of functions too  (as opposed to the above being just inline mainline code?"

    It might well do, but it would be very poor programming practice to have "side-effect" out from a function and I've never tried it in several years of writing PHP. Functions should be completely self contained. The best way to proceed with a function that generates HTML is to pass it back as a string or echo out the HTML using the ECHO statement.

    Author Closing Comment


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now