In the PHP world, outputting "Hello World!" is the first step that programmers must learn when getting started. This article will introduce how PHP outputs "Hello World!".
PHP is a widely used programming language commonly used to create dynamic web pages. In PHP, outputting text is very simple.
To output "Hello World!", just do the following two steps:
First, you need to create a file named "helloworld.php" file and save it on the web server. You can use any text editor such as Notepad, Sublime Text, VS Code, etc.
In the created PHP file, add the following code:
<?php echo "Hello World!"; ?>
This code uses the echo statement to output " Hello World!". The echo statement is the most commonly used output statement in PHP and can output any type of data.
To test the output in the browser, just enter the following URL:
http:// [Web Server Address]/helloworld.php
Where, "[Web Server Address]" is the URL address of your Web server. If you are running the web server on your local computer, the address should be: "http://localhost/helloworld.php".
Enter the URL in the browser and press Enter, "Hello World!" will be output on the page.
Summary:
Through this article, we learned how to use PHP to output "Hello World!". This is a must-have skill for any web development beginner. PHP can not only be used to output text, but can also process form data, connect to databases, generate images, and more. I hope this article can help you on your journey to learn PHP.
The above is the detailed content of How to output Hello World in php?. For more information, please follow other related articles on the PHP Chinese website!