Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

What is the basic syntax of PHP? Explain with example

PHP, which stands for Hypertext Preprocessor, is a server-side scripting language used for developing dynamic web applications.

Here is the basic syntax of PHP:

// PHP code goes here

The opening tag indicates the end of PHP code. All PHP code goes between these tags.

Here is an example of PHP code that uses variables:

$firstName = "Kunal";
$lastName = "Shinde";
$age = 18;

echo "My name is " . $firstName . " " . $lastName . " and I am " . $age . " years old.";

In this example, we declare three variables: $firstName, $lastName, and $age. We then use the echo statement to output a string that includes the values of these variables. The . operator is used to concatenate the strings and variables together.

When this code is executed, it will output the following text:

My name is Kunal Shinde and I am 18 years old.

This is just a basic example, but PHP has many more features and functions that allow developers to build complex web applications.