Home Backend Development PHP Tutorial Detailed explanation of SSI usage (2)_PHP tutorial

Detailed explanation of SSI usage (2)_PHP tutorial

Jul 13, 2016 pm 05:19 PM
include SSI two use Can Order picture Bundle insert letter document Detailed explanation

2.Include command

The Include command can insert text or pictures from other documents into the currently parsed document, which is the key to the entire SSI. With the Include command, you only need to change one file to instantly update the entire site!

The Include command has two different parameters. If you use the wrong parameters to update the site, not only will you fail to achieve the original intention, but you will get a lot of error messages.

Virtual: gives the virtual path to a document on the server side. For example:

 $#@60;!--#include virtual="/includes/header.html" --$#@62;

In order to organize the content of the site more rationally, users can create an includes subdirectory in the root directory to store all included files. The Virtual parameter can inform the server that what is to be included is a virtual file, that is, the file and the currently parsed document are not located in the same directory, but are stored in other directories. The server will find the includes subdirectory in the root directory based on the value of this parameter. Using this method, users can put all files contained in HTML documents in one directory, and save different pages in different directories or subdirectories according to their relationship. No matter which document the server parses, it can find the included files without generating any errors.

But there is a small problem that needs to be solved. Generally, we will add some TITLE and META tags to the page. If we stipulate that all pages call the same header file, it will be very inflexible. When users encounter such a problem, they can use two include files, one to set the content before the TITLE tag, and the other to set the part after the META tag, and any custom content can be added between the two include files. For example:

$#@60;!--#include virtual="/includes/header1.html" --$#@62;
$#@60;TITLE$#@62;Your Page Title$#@ 60;/TITLE$#@62;
$#@60;LINK rel = STYLESHEET href = "http://domain.com/styles/my.css" Type = "text/css" $#@62;
$#@60;META NAME = "Description" CONTENT = " Description of page"$#@62;
$#@60;META NAME = "Keywords" CONTENT = "keywords for page" $#@ 62;
$#@60;!--#include virtual="/includes/header2.html" --$#@62;

Place page content here

$#@60;!--#include virtual="/includes/footer.html" --$#@62;

From the above we can see that including headers and footers in the page can greatly reduce the workload of site updates. But what if we want to dynamically display some content, such as the last updated time of the page? No problem, we can save the included file with the .html suffix, so that we can call other included files in the included file.

File: Give? The relative path of the current directory, in which "../" cannot be used, and absolute paths cannot be used. For example:

 $#@60;!--#include file="header.html" --$#@62;

This requires each directory to contain a header.html file. Of course, using this method is not much simpler than updating every page, but it is still very convenient if the user only updates one or two files. For example, if we don't want someone unfamiliar with HTML to directly change the news page on the website, we can just let him update a separate text file and then include the file into the HMTL document, so that it will not break The original page and updated content at the same time, the best of both worlds.

3.Echo:

The Echo command can display the following environment variables:

DOCUMENT_NAME: Displays the name of the current document.

 $#@60;!--#echo var="DOCUMENT_NAME" --$#@62;

The displayed result is:

index.html

DOCUMENT_URI: Displays the virtual path of the current document. For example:

 $#@60;!--#echo var="DOCUMENT_URI" --$#@62;

The displayed result is:

 /YourDirectory/YourFilename.html

As the website continues to develop, those longer and longer URL addresses will definitely cause headaches. If you use SSI, everything will be solved. Because we can combine the domain name of the website and the SSI command to display the complete URL, namely:

 http://YourDomain$#@60;!--#echo var="DOCUMENT_URI" --$#@62;

QUERY_STRING_UNESCAPED: Displays the query string sent by the client without escaping, in which all special characters are preceded by the escape character "". For example:

 $#@60;!--#echo var="QUERY_STRING_UNESCAPED" --$#@62;

DATE_LOCAL: Displays the date and time in the time zone set by the server. Users can customize the output information by combining the timefmt parameter of the config command. For example:

 $#@60;!--#config timefmt="%A, the %d of %B, in the year %Y" --$#@62;
 $#@60;!-- #echo var="DATE_LOCAL" --$#@62;

The displayed result is:

 Saturday, the 15 of April, in the year 2000

This news has a total of 2 pages, currently on page 1 1 2

DATE_GMT: The function is the same as DATE_LOCAL, except that the date is returned based on Greenwich Mean Time. For example:

 $#@60;!--#echo var="DATE_GMT" --$#@62;

LAST_MODIFIED: Displays the last update time of the current document. Similarly, this is very practical in SSI. Adding the following simple line of text to the TML document can dynamically display the update time on the page.

 $#@60;!--#echo var="LAST_MODIFIED" --$#@62;

CGI environment variables

In addition to SSI environment variables, the echo command can also display the following CGI environment variables:

SERVER_SOFTWARE: Displays the name and version of the server software. For example:

 $#@60;!--#echo var="SERVER_SOFTWARE" --$#@62;

 SERVER_NAME: Displays the server’s host name, DNS alias or IP address. For example:

 $#@60;!--#echo var="SERVER_NAME" --$#@62;

SERVER_PROTOCOL: Displays the protocol name and version used by the client request, such as HTTP/1.0. For example:

 $#@60;!--#echo var="SERVER_PROTOCOL" --$#@62;

SERVER_PORT : Displays the server’s response port. For example:

 $#@60;!--#echo var="SERVER_PORT" --$#@62;

REQUEST_METHOD: Displays the client’s document request method, including GET, HEAD, and POST. For example:

 $#@60;!--#echo var="REQUEST_METHOD" --$#@62;

REMOTE_HOST: Displays the name of the client host that issued the request information.

 $#@60;!--#echo var="REMOTE_HOST" --$#@62;

REMOTE_ADDR: Displays the IP address of the client that issued the request information.

 $#@60;!--#echo var="REMOTE_ADDR" --$#@62;

 AUTH_TYPE: Displays the user identity verification method.

 $#@60;!--#echo var="AUTH_TYPE" --$#@62;

REMOTE_USER: Displays the account name used by the user who accessed the protected page.

 $#@60;!--#echo var="REMOTE_USER" --$#@62;

4.Fsize: Displays the size of the specified file. The output format can be customized by combining the sizefmt parameter of the config command.

$#@60;!--#fsize file="index_working.html" --$#@62;

5.Flastmod: Displays the last modification date of the specified file, and can be combined with the timefmt parameter of the config command to control the output format.

$#@60;!--#config timefmt="%A, the %d of %B, in the year %Y" --$#@62;
$#@60;!-- #flastmod file="file.html" --$#@62;

Here, we can use the flashmod parameter to display the update date of all linked pages on a page. Here’s how:

$#@60;!--#config timefmt=" %B %d, %Y" --$#@62;
$#@60;A HREF="/directory/file.html" $#@62;File$#@60;/A$#@62;
$#@60;!--#flastmod virtual="/directory/file.html" --$#@62;
$#@60;A HREF="/another_directory/another_file.html"$#@62;Another File$#@60;/A$#@62;
$#@60;!--#flastmod virtual ="/another_directory/another_file.html" --$#@62;

The displayed result is:

File April 19, 2000
Another File January 08, 2000

Some readers may think that two links are so complicated and not convenient at all. In fact, if there are 20 or more links on the page, and each link is updated regularly, you can see the use of blastmod to display the modification date.

6.Exec

The Exec command can execute CGI scripts or shell commands. How to use:

Cmd: Use /bin/sh to execute the specified string. If SSI uses the IncludesNOEXEC option, this command will be blocked.

Cgi: Can be used to execute CGI scripts. For example, in the following example, the counter.pl script in the cgi-bin directory of the server is used to place a counter on each page:

$#@60;!--#exec cgi="/cgi-bin/counter.pl" --$#@62;

This news has a total of 2Page, currently at page 2 1 2

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532650.htmlTechArticle2.Include command The Include command can insert text or pictures from other documents into the currently parsed document. It is the key to the entire SSI. Only one file needs to be changed through the Include command...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? Mar 22, 2024 am 08:06 AM

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

How to make round pictures and text in ppt How to make round pictures and text in ppt Mar 26, 2024 am 10:23 AM

First, draw a circle in PPT, then insert a text box and enter text content. Finally, set the fill and outline of the text box to None to complete the production of circular pictures and text.

How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? Mar 21, 2024 pm 09:12 PM

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the "Comment" button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a "picture" button or a "+" button, click

How to make ppt pictures appear one by one How to make ppt pictures appear one by one Mar 25, 2024 pm 04:00 PM

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

How to arrange two pictures side by side in wps document How to arrange two pictures side by side in wps document Mar 20, 2024 pm 04:00 PM

When using WPS office software, we found that not only one form is used, tables and pictures can be added to the text, pictures can also be added to the table, etc. These are all used together to make the content of the entire document look richer. , if you need to insert two pictures into the document and they need to be arranged side by side. Our next course can solve this problem: how to place two pictures side by side in a wps document. 1. First, you need to open the WPS software and find the picture you want to adjust. Left-click the picture and a menu bar will pop up, select "Page Layout". 2. Select "Tight wrapping" in text wrapping. 3. After all the pictures you need are confirmed to be set to "Tight text wrapping", you can drag the pictures to the appropriate position and click on the first picture.

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

See all articles