Posted By:
7 Mar, 2014 5:35 am PST

HOW TO WRITE BASIC PHP CODE TO DISPLAY MESSAGE

 

  HOW TO WRITE BASIC PHP CODE TO DISPLAY MESSAGE

 

Php code always resides in following tag. This tag can be put any where in web document

<? PHP

// write your code here

?>

Q) Write a program to print message on web page.

 

Example

// to display message on screen

<? PHP

echo " <h2 > " ;

echo " Hello World !!!!! This is my First PHP CODE " ;

?>

 

Only thing we have to make sure that the extension should “.php”.

 

 

Hello World

 

 

 

Attachment: HelloWorld.php


How to print any word or sentence  in PHP?

The PHP interpreter runs the commands between  <?php  (the PHP start tag) and  ?> (the PHP end tag). PHP pages typically live in files whose names end in .php.Here we use keyword echo to print on the screen.

 

//To print  sentence using PHP

 

<!DOCTYPE html>

<html>

<body>

<?php   

echo "My first PHP script!";

?>  

</body>

</html>

 

 

/*Output of the above program:

My first PHP script

*/

Attachment: MyPHP.php
Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud