How to code a PHP application

As we know PHP  is a server-side scripting language. For Code, a PHP starts with <?php and ends with ?>.

PHP can embed with HTML and JavaScript.

Here I a putting an example

<!DOCTYPE html>



<h1> KSH TUTOR News</h1>

<?php echo “KSH TUTOR is a good website for scholars.”; ?>



In the above example, we can see how PHP embeds with HTML.

When we run this PHP code on the browser, we get the following output:-


KSH TUTOR is a good website for scholars.

In our next example, I shall show how PHP code deal with HTML <form>

<!DOCTYPE html>



<form method=”post” action=”target.php”>

First Name:  <input type=”text” name=”fname” /><br />

Last Name:  <input type=”text” name=”lname” /><br />

<input type=”submit” name=”submit” value=”Submit” /><br />




In our target.php file:-

echo $_POST[‘fname ‘];

echo “<br/>”;

echo $_POST[‘lname ‘];

Comments in PHP:- A comment is basically useful for reading and understanding the code. It is non-executed.

PHP support two type of comment:-

  1. Single Line Comment:- Single line comments may write following two ways:-

// PHP Single-line comment

#PHP single-line comment

  1. Multiple Line Comment:- Multiple line comments can be written:-

/* First Line Comment

End of Multiple Line Comment*/


Variables in PHP:- PHP variables are case-sensitive.  It starts with the $ sign.

$total and $Total both are different variables.

Variables can start with an upper case or lower case letter or underscore.

except underscore any other special characters are not allowed for variable names.

Read Also:-


PHP Global Variable $_GET

PHP Global Variable $_SERVER


PHP predefined variables

For more detail about variables please see manual

Share with:

Leave a Reply

Connect with:

Verified by ExactMetrics