PHP Basics: Simple Basic Code


To print a simple program in PHP is a simple example of a basic PHP script. PHP is a popular server-side scripting language used for web development, and the creating print Welcome note is often the first program that developers create when learning a new programming language. The program uses the echo statement to display the string "Welcome!" to the web page or the browser. It serves as a starting point for beginners to understand the syntax and structure of PHP code, and it's commonly used as a first step to test the installation and configuration of a PHP environment.

Here's a step-by-step guide on how to create PHP projects in XAMPP htdocs directory

  • Access htdocs directory : Open the XAMPP installation directory on your machine and locate the "htdocs" directory. This is the default web root directory where you can create your PHP projects.
  • Create a new directory for your PHP project : Inside the "htdocs" directory, create a new directory with a name of your choice, which will be the name of your PHP project. For example, you can create a directory called "youtube".

  •  PHP project folder

  • Add your PHP files : Inside the "youtube" directory (or the name you gave to your project directory), you can create and add your PHP files, HTML files, CSS files, JavaScript files, and any other files required for your PHP project.
  • Access your PHP project in the web browser : Once you have added your PHP files to the "htdocs" directory, you can access your PHP project in a web browser by entering the following URL in the address bar: "http://localhost/youtube" (replace "youtube" with the name of your project directory).

Your PHP project will now be accessible in the web browser, and you can test and run your PHP code from here.

Note: It's important to note that the "htdocs" directory in XAMPP is the root directory of your local web server, so any PHP files or projects stored in this directory will be accessible through the web server at "http://localhost/". Always exercise caution when developing locally and avoid using sensitive or production data on your local server.

Sample Code

<?php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Welcome to PHP Tutorial By Tutor Joes</h1>
</body>
</html>
?>

Output


Basic Code