articles

Home / DeveloperSection / Articles / Displaying message in PHP

Displaying message in PHP

Anonymous User5659 02-Sep-2011

Here we have an example for showing simple PHP scripting code which sends the text ‘Hello Word’ to client browser.

Example:  Displaying message using ‘echo’ statement.

 Here we have an example, how to display a message using ‘echo’ statement with PHP.

Note: Here I am using notepad text editor to write the following code.

Example 1: Display ‘Hello Word’ text.

<html>
  <head>
        <title>Hello Word</title>
 </head>
<body>
       <?php
              echo "Hello Word";
        ?>
</body>
</html>

 

Output:

Displaying message in PHP

Example2: Use html tag with ‘echo’ statement.

<html>
  <head>
<title>My file</title>
</head>
<body>
       <?php
              <%-- // here $faname is a variable--%>
              $fname = "Arun Singh";
              <%--// here </br> is a html tag to break line
              // here . (Dot operator) used for concatenate two string--%>
              echo "Welcome "." ". $fname." ". "</br>". "in"  ;
              <%--// here <h5> </h5> is a heading tag --%>
              echo "<h5>". "Mindstick". "</h5>";
        ?>
</body>
</html>

 

Output:

Displaying message in PHP

Example 3: Display numeric value with ‘echo’ statement.


<html>
  <head>
<title>My file</title>
</head>
<body>
       <?php
              <%--// assigned numeric value in variable 'decimal'--%>
              $decimal = 105;
              echo $decimal ;
        ?>
</body>
</html>
Output:

Displaying message in PHP

Each code line in PHP should have semicolon at the end of line, because semicolon (;) is a separator used to distinguish one line code to another one.

Note: File must have php extension such as .php, .php3 or .php4 etc. Now save this file with ‘helloword.php’ name.  

Deploying php file into WAMP Server:

To deploy ‘helloword.php’ file into WAMP server, open the directory where wamp server is installed, and suppose that the installed directory path is ‘C: \wamp\’, open ‘C: \wamp\www\’ directory path and create a folder and put all .php file in it.

Now let’s have snapshot, how to deploy .php file into wamp server.

Step 1:  Open ‘C: \wamp\’ directory.

Displaying message in PHP

Click on ‘WWW’ directory.

Step 2: Create your own directory to store .php file.

Displaying message in PHP

Click on ‘MyFiles’ directory. 

Displaying message in PHP

Step 3: To open this file on web browser, start wamp server and click on ‘localhost’

Displaying message in PHP

Click on ‘My files’ directory.

Displaying message in PHP

Click on ‘helloword.php’ file link.

Displaying message in PHP

This is your desired result.

Displaying message in PHP



Updated 04-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By