PHP echo - print statements

php use echo and print construct to output the given argument.

PHP echo not required to use parentheses, because is not actually a function, it is a language construct.

the echo can take more than one parameter when used without parentheses.

the PHP echo statement does not return any value.

this example shows how to display strings, variables, image and textarea with the echo statement:

        $x = 40;  $y = 3434.43434; $bool = true ;
        $web = "";
                  echo "<p>this is the string</p>";
                  echo "<h1>the x value = $x  </h1>";
                  echo "<br/>";
                  echo '<p>'."{$y}".'</p>';
                  echo  "<p><img  src='../../images/websuccess.jpg' 
                    width='259px;' height='160px;' /></p>"; //image output for user
                  echo("<br/><textarea   rows='7'  ='20'>this is the textarea send by 
                                                        php echo function </textarea>");           

php echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled within php.ini file.


         <?= expression  ?>
                  $x = 303;
                  $name = "";
                  $salary="this is php echo statement";
      <?= $x ?>
      <?= $name ?>  <br/>
      <?= $salary ?>         

the PHP print statement

the php print statement is a language construct so you can used with or without parentheses :- print or print().

it can output all types of data

print always returns 1.

this example shows how to display strings, variables and image with the print statement:

             $xx= 20;  $yy=50;
             $data = 'w3webtutorial' ;
             print("<p>the xx value = {$xx} </p>");