After installing xampp you are ready to start with php. This is our first blog through which you can learn php.
So let me start with the Hello World program in PHP. Following script displays the sentence “Hello, World!” in the browser. It is a simple and straight forward code. There are two basic ways of doing this hello world print and they are using ‘echo’ or ‘print’.
The difference between using ‘echo’ and ‘print’ is,
- the echo statement just prints the arguments passed to it and does not return any value. But the ‘print’ statement prints the argument as well as returns a value of 1. Since it returns a value, ‘print’ statement can be used in expressions.
- the echo statement can take multiple parameters and print statement takes only one parameter.
Example Hello World Code using Echo
<?php echo "Hello, World!"; ?>
Example Hello World Code using Print
<?php print "Hello, World!"; ?>
In this context of printing ‘Hello, World!’, both ‘echo’ and ‘print’ are same.
Comments
Post a Comment