Home > Backend Development > PHP Problem > How to write a web page using php

How to write a web page using php

angryTom
Release: 2023-02-28 10:36:02
Original
14229 people have browsed it

How to write a web page using php

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 &#39;<p>Hello World</p>&#39;; ?>
 </body>
</html>
Copy after login

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
Copy after login

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>
Copy after login

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(); ?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template