php print array - Wikitechy https://www.wikitechy.com/interview-questions/tag/php-print-array/ Interview Questions Tue, 02 Aug 2022 12:35:01 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png php print array - Wikitechy https://www.wikitechy.com/interview-questions/tag/php-print-array/ 32 32 What is echo and print in PHP ? https://www.wikitechy.com/interview-questions/php/what-is-echo-and-print-in-php/ https://www.wikitechy.com/interview-questions/php/what-is-echo-and-print-in-php/#respond Tue, 02 Aug 2022 12:35:01 +0000 https://www.wikitechy.com/interview-questions/?p=4560
  • PHP is not a function; it is a language construct and its output become one or more string.
  • If you want to pass more than one parameter to echo, the use of parentheses is required.
  • PHP echo statement is used to print the string, array, variable multi-line strings, escaping characters, etc.
  • Echo is used to display the output, because it is a statement and does not return any value.
  • Echo can be used with echo () or without parentheses echo.
  • In echo, we can pass multiple strings separated by a comma (,).
  • The PHP print can be used alternative to echo many times and its statement is similar to the echo statement.
  • In PHP print accepts one argument at a time & cannot be used as a variable function.
  • Echo is faster than the print statement and print outputs only the strings.
  • The main difference between the echo and print statement is that echo does not behave like function whereas print behave like a function.
  • Sample Code : Echo Statement





    echo "

    PHP is Fun!

    ";
    echo "Welcome to wikitechy!
    ";
    echo "I'm about to learn PHP!
    ";
    echo "This ", "string ", "was ", "made ", "with multiple parameters.";
    ?>


    Output

    Sample Code: Print Statement





    $txt1 = "Learn PHP";
    $txt2 = "Wikitechy.com";
    $x = 5;
    $y = 5;

    print "

    " . $txt1 . "

    ";
    print "Study PHP at " . $txt2 . "
    ";
    print $x + $y;
    ?>


    Output

    ]]>
    https://www.wikitechy.com/interview-questions/php/what-is-echo-and-print-in-php/feed/ 0