PHP is a server side scripting language. that is used to develop Dynamic websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages.
To write your first PHP program, you will need a text editor and a web server that is configured to run PHP.
- Open your text editor and create a new file.
- Add the following line at the top of the file:
<?php
This is the opening PHP tag and it tells the web server that the code that follows is written in PHP.
- Next, write your PHP code. For example, you can write a simple program that outputs the text “Hello, World!” like this:
<?php
echo "Hello, World!";
?>
- Save the file with a
.php
extension. - Copy the file to the root directory of your web server. The root directory is the directory where your web server looks for files to serve when it receives a request.
- In your web browser, visit the URL of the file you just saved on your web server. For example, if the file is saved in the root directory of your web server and the web server is running on your local machine, you might visit
http://localhost/your-file.php
.
You should see the text “Hello, World!” displayed in your web browser.
This is just a simple example of a PHP program. PHP is a powerful programming language that can be used to create dynamic and interactive websites.
<html>
<head>
<title>First PHP Code</title>
</head>
<body>
<?php echo "Hello, world!"; ?>
</body>
</html>
Leave a Reply