Skip to content

Learn & Explore

Learn practical technology, programming, IT infrastructure, cybersecurity and real-world experiences.

  • Home
  • Learn
    • IT Fundamentals
      • What Is Information Technology?
      • History and Evolution of Computer Technology
      • Components of an Information Technology System
    • Java
      • Introduction to Java: What It Is & Why Learn It
    • Programming
    • Web Development
    • Networking
    • Cyber Security
    • Database
    • Roadmaps
      • Java Roadmap
  • Resources
    • Technology Pioneers
      • Charles Babbage
      • Ada Lovelace
      • Alan Turing
      • Grace Hopper
      • Tim Berners-Lee
      • Dennis Ritchie
      • Linus Torvalds
    • IT Degrees in Nepal
      • BSc CSIT(TU)
    • Universities
      • Tribhuvan University
      • Kathmandu University
      • Pokhara University
      • Purbanchal University
      • Mid-West University
      • Far Western University
      • Nepal Open University
    • Quotes
  • About
    • Contact
    • Privacy Policy
    • Terms and Conditions
  • Home
  • Programming
  • Writing first PHP program

Writing first PHP program

Posted on December 6, 2022December 29, 2022 By macharaja No Comments on Writing first PHP program
PHP, Programming

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.

  1. Open your text editor and create a new file.
  2. 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.

  1. 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!";
?>
  1. Save the file with a .php extension.
  2. 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.
  3. 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>

Post navigation

❮ Previous Post: Resolve Oracle 19 C installation INS-08101 Unexpected Error
Next Post: What is HTML ? ❯

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • IT Career Guide for College Students in Nepal: A Complete Roadmap to Success
  • Procedural Programming vs Object-Oriented Programming (POP vs OOP)
  • What is Programming? A Beginner’s Complete Guide
  • Introduction to Object-Oriented Programming (OOP): Concepts, Features, and Benefits
  • Difference Between C and C++

Categories

  • C & C++
  • C#
  • Course
  • CSS
  • Cyber Security
  • Database
  • HTML
  • IT Career
  • IT Degrees
  • IT Degrees in Nepal
  • IT Fundamentals
  • Java
  • JavaScript
  • Microsoft SQL Server
  • My Learnings
  • MySQL
  • Oracle
  • PHP
  • Programming
  • Quotes
  • Technology
  • Technology Pioneers
  • Universities
  • Web Development
  • Web Hosting

Copyright ©2026