How to make a php page

藏色散人
Release: 2023-02-27 14:52:02
Original
4404 people have browsed it

How to make a php page

How to make a php page?

The first PHP page

Create a file named hello.php under the web server root directory (DOCUMENT_ROOT), and then complete the following content:

Example #1 The first PHP script: hello.php

<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, and add "/hello.php" at the end . If developing locally, this URL is usually http://localhost/hello.php or http://127.0.0.1/hello.php, depending on the web server settings. If all settings are correct, then this file will be parsed by PHP, and the following result will be output in the browser:

<html>
 <head>
  <title>PHP 测试</title>
 </head>
 <body>
 <p>Hello World</p>
 </body>
</html>
Copy after login

This program is very simple, it just uses PHP's echo statement to display Hello World . Users will definitely not be satisfied with this. 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!

If you have tried this example but did not get any output, or the browser pops up a download box, or the browser displays the source file in text mode, the possible reason is that the server does not yet support PHP, or does not Configure correctly. You need to ask the server administrator to make the server support PHP according to the contents of the "Installation" chapter of this manual. If developing locally, please read the installation section of the manual to make sure everything is set up correctly. Also verify that the URL accessed through the browser actually points to this file on the server. If this file is simply called from the local file system, it will not be parsed by PHP. If the problem persists, get help from one of the options at » PHP Online Support.

The purpose of the above example is to show the format of PHP special identifiers. In this example, use .

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to make a php page. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!