Forum

array

This thread contains 3 replies, has 4 voices, and was last updated by Anonymous 1 year, 7 months ago.

  • Author Replies
    • #34738

      Different Between Echo and Print ?


    • #34764

      Hello Rushi,

      print is used to print a single line whereas we can use multiple lines with echo function.

      Example:

      $str = “Hello meet”;

      $str1 = “Patel”;

      print $str;  // Output will display a “Hello meet” when you will run the script

      print $str,$str1; // Output of this line will be a syntax error.

      echo $str,$str1; // Output of this line will be a “Hello meet patel”;

       

      Moreover echo is faster than the print statement.


      Php-Mentor

    • #34796

      Hello ,

      echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument.

       

      For Example :-

      echo “This “, “string “, “was “, “made “, “with multiple parameters.”; //this is valid

      Print “This “, “string “, “was “, “made “, “with multiple parameters.”; // this is not valid


    • Anonymous
      #50599

      Hey Meet,

      In a nutshell, echo and print both are PHP Statement.
      Both are used to display the output in PHP.

      Echo:

      1. It can be used with or without parentheses;
      2. echo can pass multiple strings separated as ( , );
      3. echo doesn’t return any value

      Print

      1. Print can don’t pass multiple arguments
      2. Print always return 1
      3. It is slower than echo

       

      Hope this helps!


Viewing 3 reply threads

You must be to reply to this thread.Please or . Registration is 100% free.

GET FREE CONSULTATION

Call Us Now For Free Consultation97370 05566

Our experts listen to you patiently and suggest you the right course after conducting a personality profile test. Register your interest below to schedule personality profile test for you.

SUBSCRIBE TO OUR NEWSLETTER

Contact Us

Working Hours

  • Monday9:00 AM – 9:00 PM
  • Tuesday9:00 AM – 9:00 PM
  • Wednesday9:00 AM – 9:00 PM
  • Thursday9:00 AM – 9:00 PM
  • Friday9:00 AM – 9:00 PM
  • Saturday9:00 AM – 9:00 PM
  • SundayClosed
Copyright 2016-2020 Smart Mentors. All Rights Reserved.

Login

FORGOT PASSWORD

Sign up now to Become An Instructor

Register your Interest