How to write a web page using php
Create a file named index.php in the root directory of the web server file, and then complete the following content:
<html> <head> <title>第一个php网页</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>
Enter the URL of the web server in the browser's address bar to access this file. If you develop locally, this URL is usually http://localhost/index.php or http://127.0.0.1/index.php, of course, this depends on the web server settings. If all settings are correct, then this file will be parsed by PHP, and the following results will be output in the browser:
Hello World
Right-click to view the source code and the following code will appear
<html> <head> <title>第一个php网页</title> </head> <body> <p>Hello World</p> </body> </html>
This program It's very simple, it just uses PHP's echo statement to display Hello World. Note that this file does not need to be executed or specified in any way. The server will find the file and provide it to PHP for interpretation because the ".php" extension is used. The server has been configured to automatically pass files with a ".php" extension to PHP. An ordinary HTML file, with a few special tags added, can do a lot of very interesting things!
Now you can try to replace Hello World
'; ?> with the following code, and then open the browser to take a look.<?php phpinfo(); ?>
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to write a web page using php. For more information, please follow other related articles on the PHP Chinese website!