![]() |
Whenever we start to learn any programming language, we often begin by writing or printing “Hello World”. In this article, we will see how to print “Hello World” using PHP. To print “Hello World” on the screen using PHP. There are two most common methods for printing “Hello World” messages which are as follows: Table of Content Using the PHP CLI MethodThe PHP CLI method allows you to run PHP scripts directly from the command line. This approach is useful for testing simple scripts, running maintenance tasks, or performing operations without the need for a web server. Example: To demonstrate printing a simple “Hello World” message using the PHP.
Output Hello, World! Using PHP server methodThe PHP server method involves running PHP scripts through a web server, such as Apache or Nginx, which processes the PHP code and sends the output to the browser. This method is commonly used for developing and testing web applications. Step 1: Install XAMPP or any other PHP server package. Step 2: Create a PHP File: Create a file named
Step 3: Place the File in the Web Root Directory: Move the
Step 4: Start the Server: Open a terminal and start the XAMPP server: sudo /opt/lampp/lampp start Step 5: Access the File in a Browser: Open your web browser and navigate to
Output: ![]() PHP Hello World |
Reffered: https://www.geeksforgeeks.org
PHP |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 23 |