Comparing echo and print: Understanding the Differences in PHP

In php echo and print both are used for showing output on the user screen.

Here we are going to discuss some differences between both statements.

1. echo Statement
  • we can write echo statement with parenthesis like 'echo()' or without parenthesis 'echo'.
  • in the echo we can pass multiple variable in comma separated form to see the output like 'echo $a,$b,$c;'
  • echo doesn’t return any value
  • echo is faster then print
      Example:

      1.    <?php
                   echo "hello world";
                  // or
                  echo("hello world");
             ?>
      Output: hello world

      2.    <?php
                   $a = "Hi ";
                   $b = "this is ";
                   $c = "Ap here";
                   echo $a,$b,$c;
             ?>
      Output: Hi this is Ap here.

      3.    <?php
                   $a = "Raj";
                   $name = echo $a;             ?>
      Output: Parse error: syntax error, unexpected T_ECHO
    

2. Print Statement
  • we can write print statement with parenthesis like 'print()' or without parenthesis 'print'.
  • in the print we can not pass multiple variable in comma separated form like echo.
  • print statement always returns 1.
  • print is slower than echo
      Example:

      1.    <?php
                   print "hello world";
                  // or
                  print("hello world");
             ?>
      Output: hello world

      2.    <?php
                   $a = "Hi ";
                   $b = "this is ";
                   $c = "Ap here";
                   print $a,$b,$c;
             ?>
      Output: Parse error: syntax error

      3.    <?php
                   $a = "Raj";
                   $name = print $a;
                   echo $name;
             ?>
      Output: Raj
 
So, If you are having any query and doubt regarding this concept then you can ask in comments. 
Thank You !!!

How to stop VMware port error of 443 on XAMPP Control Panel v3.2.2

While starting the apache service in xampp control panel v3.2.2 shows error as below image

apache_error

To resolve this error follow steps one by one :

Step 1: 
Open Up 'httpd-ssl.conf' file by locating in 'C:\xampp\apache\conf\extra' directory or you can just open 'httpd-ssl.conf' file from xampp control panel by clicking on config button against apache service. 
httpd_conf_file


Step 2:
After opening 'httpd-ssl.conf' file look for the line 'Listen 443' by pressing 'Ctrl + f'

Step 3:
Go on that line Change port number to anything you want. I use 4440. ex. Listen 4440. and Replace every 443 string in that file with 4440.


Step 4:
After all changes done then Save 'httpd-ssl.conf' file.

 start_apache_service

If you are having any query and doubt regarding this configuration then you can ask in comments.  


Thank you !!