谈谈生成静态页面的一些经验
作者: q3boy
静态页面的生成一般有这么几个思路了。。
1。程序编写过程中。不使用直接输出的语句。而时将所有的输出连接至输出字符串,输出完成后。再直接将输出字符串内容写入文件
2。编写中按照正常的方式编写。通过ob函数组捕获输出。然后将输出写入文件
3。使用模板类时,用get/fetch一类的方法获取输出。并写入文件。
具体实现上又有这两种方法
1。管理后台添加记录时,直接生成目标html页面,并且前台调用连接直接指向生成的html页面。这种方法程优点是程序效率最高。服务器负荷轻,不过由于生成的是纯静态页面,一旦页面样式上有所改动就必须重新生成所有的内容页。所以实际使用中应用一般不是太多。更多的是使用js,ssi,xml/xsl等客户端手段,生成的静态文件中仅保存数据,不涉及样式,这样能达到速度和维护性的平衡,不过相对前后台程序要复杂些(应用这种方法时,由于内容为纯静态,可以搭配单独编译的纯静态的apache使用。。效率和资源占用上比包含动态内容支持的要更佳)
2。前台访问链接指向php程序,php程序首先检查是否存在相应的静态文件。如果静态文件不存在。则生成并重定向至此文件,否则直接重定向。这种方法实际使用中一般和apache的url_rewrite功能一起使用。将php的文件地址重为html的形式,有利于搜索引擎的检索。这种方法在效率上略有损失,不过程序结构简单,便于调整,在访问量不是很大时使用很合适。。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

C++ is a widely used programming language that is very convenient and practical in writing countdown programs. Countdown program is a common application that can provide us with very precise time calculation and countdown functions. This article will introduce how to use C++ to write a simple countdown program. The key to implementing a countdown program is to use a timer to calculate the passage of time. In C++, we can use the functions in the time.h header file to implement the timer function. The following is the code for a simple countdown program

Do you frequently visit the same website at about the same time every day? This can lead to spending a lot of time with multiple browser tabs open and cluttering the browser while performing daily tasks. Well, how about opening it without having to launch the browser manually? It's very simple and doesn't require you to download any third-party apps, as shown below. How do I set up Task Scheduler to open a website? Press the key, type Task Scheduler in the search box, and then click Open. Windows On the right sidebar, click on the Create Basic Task option. In the Name field, enter the name of the website you want to open and click Next. Next, under Triggers, click Time Frequency and click Next. Select how long you want the event to repeat and click Next. Select enable

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

Windows 10 and 11 come with multiple apps that you probably don't need. According to reports, one more app has joined the bloatware list, the HPSmart app. A report by WindowsLatest says they noticed that a new app called HPSmart has been added to the Start menu of their Windows 10 laptops. However, it didn't end there, the authors discovered that the application had also been automatically installed on their virtual machine running on Windows 11. What’s interesting about this situation is that the report states that the app automatically installs even when no HP product is connected to the PC. Some users reported on reddit that they also encountered similar

If you're using a multi-monitor setup and your apps keep opening on the wrong monitor in Windows 11, this guide can help! We'll discuss some practical ways to turn off multiple monitors on Windows so that your apps open on the primary monitor. Why do programs open on my second monitor? Previously used the program on a second monitor and closed it while the app was on it. Display settings in the operating system may be configured to open new programs on this screen. The secondary monitor has been reconnected or the monitor configuration has been changed. Some apps have glitches or bugs that may cause them to open on the wrong monitor, regardless of settings. How to make a program open Windo on a specific monitor

To solve the problem that the program still cannot run after configuring Java environment variables, you need specific code examples. Title: Java environment variable configuration problem and solution. Introduction: With the widespread application of Java programming technology, configuring Java environment variables has become a must for programming beginners and developers. One of the prepared skills. However, sometimes even if the Java environment variables are configured correctly, you still encounter the problem that the program cannot run. This article will share some steps to solve the problem that the program cannot run after configuring Java environment variables to help readers successfully solve related problems.
