How to write program in php?

In PHP, it is very easy to write program.

  • First open note pad or any text editor.
  • write html code and php code.
  • then save your file with .php extension under www folder in WAMP server or htdocs folder in xampp server.

Example :- How to write PHP program?

File Name : index.php

<html>
<head>
<title></title>
</head>
<body>
<?php

echo "Hello mahtab Habib";

?>
<br>
<?php
echo "<h2>Hello Sana Mahtab</h2>";
?>
</body>
</html>

 

Output :-

 

Hello mahtab Habib
Hello Sana mahtab

Difference Between echo and print.

  • Echo is slightly faster than print.
  • Parameters : echo allows more than one parameter where as print does not.
  • Expression :- print works like a function and returns true value after successfully executed.

 

Example

File Name : index.php


<? Php
print "Hello PHP", "Hello java";
// it will generate error.
?>
Whereas
<? Php
echo "Hello Php", " Hello java";
?>


Output :-

Hello Php Hello java





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here