Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    PHP Program to Print Hello World

    This PHP Hello World tutorial will teach you how to use the PHP echo and print statements to display output in a web browser. The primary purpose of this example program is to explain to beginners how to print on PHP.

    Display String as Output

    Example:

    The following example shows how to use an echo statement to display "Hello World!".

    <?php
    echo 'Hello, World!';
    ?>

    Program Output:

    Hello, World!

    Display HTML Code as Output

    Example:

    The following example shows how to use echo statements to display an HTML Code.

    <?php
    echo "<h1>Page Heading</h1>";
    print "<p style='font-weight:bold; color:blue;'>This is a paragraph text styled with CSS.</p>";
    ?>

    Program Output:

    Page Heading

    This is a paragraph text that is styled with CSS.

    The print and echo both are language constructs, not functions. These two statements are substitutes and do exactly the same, except that the print statement always returns 1.



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.