Home Backend Development PHP Tutorial 睡觉有关问题早晚成为小弟我顶头疼的有关问题。PHP

睡觉有关问题早晚成为小弟我顶头疼的有关问题。PHP

Jun 13, 2016 pm 12:27 PM
echo get

睡觉问题早晚成为我顶头疼的问题。。。-PHP

  hi

昨晚又作自己,睡不好整个人都不好。。。

1、PHP实现页面静态化

二、纯静态化

2.2 实现页面纯静态化的原理

--基本方式

file_put_contents()函数;

使用php内置缓存机制,output_buffering.

具体信息可以去php手册中查找。重点看函数格式,参数,返回值。

--栗子file_put_contents()

/*
* 写入函数
*/

file_put_contents('index.shtml','asdklfj');

运行http://localhost/phpJingtaihua/index.shtml,得到结果。很简单的一个函数。

--栗子output_buffering

有内置函数,ob(output_buffering)系列的。

主要涉及四个

ob_start,打开输出控制缓冲;

ob_get_contents,返回输出缓冲区内容;

ob_clean,清空输出缓冲区;

ob_get_clean,得到缓冲区内容并删除当前输出缓冲区。

ob_start(); //打开缓冲区
echo 1234;
echo ob_get_contents();

得到12341234的序列。也就是说,所有输出都要经过缓冲区——就像是水龙头上装了个滤嘴。

ob_start(); //打开缓冲区
echo 111;echo "
";
echo ob_get_contents();echo "
";
ob_clean();
echo ob_get_contents();echo "
";

echo 222;echo "
";

echo ob_get_clean();echo "
";

这里呢,111因为缓冲区的清除,而不会再输出,即使是原始的echo语句也不行。

2.3 纯静态化案例实现简介

终极目的就是生成静态文件。

其一,写入数据到静态文件。

其二,利用ob机制,获取(可以写入到静态文件的)数据。

2.4 案例实现步骤

链接数据库,从数据库中获取数据——》把获取到的数据填充到模板文件中去——》把动态页面转化为静态页面,生成纯静态文件。

 

-----------------

先这样,晚上有时间再写。。。。

 

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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 automate tasks using PowerShell How to automate tasks using PowerShell Feb 20, 2024 pm 01:51 PM

If you are an IT administrator or technology expert, you must be aware of the importance of automation. Especially for Windows users, Microsoft PowerShell is one of the best automation tools. Microsoft offers a variety of tools for your automation needs, without the need to install third-party applications. This guide will detail how to leverage PowerShell to automate tasks. What is a PowerShell script? If you have experience using PowerShell, you may have used commands to configure your operating system. A script is a collection of these commands in a .ps1 file. .ps1 files contain scripts executed by PowerShell, such as basic Get-Help

How does java initiate an http request and call the post and get interfaces? How does java initiate an http request and call the post and get interfaces? May 16, 2023 pm 07:53 PM

1. Java calls post interface 1. Use URLConnection or HttpURLConnection that comes with java. There is no need to download other jar packages. Call URLConnection. If the interface response code is modified by the server, the return message cannot be received. It can only be received when the response code is correct. to return publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

Five selected Go language open source projects to take you to explore the technology world Five selected Go language open source projects to take you to explore the technology world Jan 30, 2024 am 09:08 AM

In today's era of rapid technological development, programming languages ​​are springing up like mushrooms after a rain. One of the languages ​​that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Go language development essentials: 5 popular framework recommendations Go language development essentials: 5 popular framework recommendations Mar 24, 2024 pm 01:15 PM

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Jun 13, 2023 pm 05:01 PM

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets

Detailed explanation of the role and usage of the echo keyword in PHP Detailed explanation of the role and usage of the echo keyword in PHP Jun 28, 2023 pm 08:12 PM

Detailed explanation of the role and usage of the echo keyword in PHP PHP is a widely used server-side scripting language, which is widely used in web development. The echo keyword is a method used to output content in PHP. This article will introduce in detail the function and use of the echo keyword. Function: The main function of the echo keyword is to output content to the browser. In web development, we need to dynamically present data to the front-end page. At this time, we can use the echo keyword to output the data to the page. e

Example of Curl Get command Example of Curl Get command Mar 20, 2024 pm 06:56 PM

In Linux, URL or Curl client is a popular command line utility that allows you to transfer data over the network using various protocols such as HTTPS, HTTP, FTP, etc. It allows you to send and receive data using its get, post and request methods. Among them, you need to use the "get" method frequently. Therefore, it becomes crucial to learn various methods and various options that you can use to increase your productivity. "Performing a curl operation is as simple as entering a few simple commands. Although it seems simple, many users do not fully realize its potential. Therefore, this short guide provides some information on how to perform curl operations on Linux systems. Example using the "curlget" command." Curl

What are the most popular golang frameworks on the market? What are the most popular golang frameworks on the market? Jun 01, 2024 pm 08:05 PM

The most popular Go frameworks at present are: Gin: lightweight, high-performance web framework, simple and easy to use. Echo: A fast, highly customizable web framework that provides high-performance routing and middleware. GorillaMux: A fast and flexible multiplexer that provides advanced routing configuration options. Fiber: A performance-optimized, high-performance web framework that handles high concurrent requests. Martini: A modular web framework with object-oriented design that provides a rich feature set.

See all articles