Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is diffrence between echo and print in PHP ?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 120
    Comment on it

    Hello all, Welcome to FindNerd, today we are going to discuss the difference between echo and print statement in PHP ?


    echo and print both are used to printing a statement.
    So here are few important point given below to differentiate between echo and print


    lets start with "echo" statement

    echo statement is more faster than print and echo never return a value.
    In echo statement we can pass multiple strings separated with (,).

    You can see bellow example of echo statement:

    <!DOCTYPE html>
    <html>
    <body>
    
    <?php
    echo "Hi Mac .<br>";
    echo "How are you ?<br>";
    echo "I'am fine joe!<br>";
    echo "What ", "about ", "You?";
    ?>  
    
    </body>
    </html>
    


    output will come:

    Hi Mac .
    How are you ?
    I am fine joe!
    What about You? 

    Now let start "print" statement
    Print statement always return 1 and in print statement we can not pass multiple arguments.
    This statement can be used with or without parentheses.

    You can see bellow example of print statement:

    <?php
    print "Hi Mac <br>";
    print "I am also fine.";
    
    ?> 
    


    output will come:

    Hi Mac
    I am also fine. 

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: