PHP Hello World!
Creating a “Hello, World!” program in PHP is simple. Follow these steps:
- Create a PHP File: Open a text editor of your choice (like Notepad, Visual Studio Code, etc.) and create a new file with a .php extension. For example, name it hello.php.
- Write the PHP Code: Inside the file, write the following PHP code:
<? php
echo “Hello, World!”
?>
3.Save the File: Save the file.
4.Run the PHP Script: If you have a local PHP development environment set up, you can run the script in you your web browser or through the command line. If you are using a tool like XAMPP or MAMP, place the file in the web server’s document root and access it through a browser.
Alternatively, if you have PHP installed on your computer, you can run it form the command line. Open a terminal or command prompt, navigate to the directory where your hello.php file is located, and run:
phphello.php
You should see the output:
Hello, World!
Congratulations! You’ve just created executed a simple “Hello, World!” program in PHP. This is often the first step when learning a new programming language.