Different ways to write a PHP code (original) (raw)

Last Updated : 05 Mar, 2021

The full form of PHP is a Hypertext preprocessor. It was developed by Rasmus Lerdorf. It is a programming language for developing dynamic web applications and interactive websites. It is a server-side scripting language. It is used for establishing a connection between the front-end and database i.e., back-end.

Ways to run a PHP program:

Like this we have to save the PHP file

After saving your code file into the htdocs folder follow the below steps.

A PHP code can be written in 3 ways

  1. Without any HTML markups
  2. Embedding HTML markups in PHP code
  3. Embedding PHP code in HTML.

1. Without any HTML markups:

PHP `

c=c=c=a+$b; echo("The addition of a and b is ". $c); ?>

`

Output :

The addition of a and b is 20

2. Embedding HTML markups in PHP code:

PHP `

"; echo "

welcome

" ; echo "" ; ?>

`

Output:

welcome

3. Embedding PHP code in HTML:

PHP `

`

Output:

Your first PHP code

The most proficient way: