Home > Backend Development > PHP Tutorial > nginx custom string

nginx custom string

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:11:55
Original
1180 people have browsed it

ngx_str_t是nginx自定义的字符串格式,其定义在ngx_string.h中,如下:

<code><span>typedef</span><span>struct</span> {
    size_t      len; <span>//字符串长度,不含'\0'</span>
    u_char     *data; <span>//真正字符串</span>
} ngx_str_t;</code>
Copy after login

它本质上就是一个结构体,nginx中广泛使用这种格式字符串。
优点:减少对字符串长度的计算次数,nginx作为web服务器大量的会计算字符的长度;可以随时被引用,减少字符串拷贝带来的性能损失。

对这种字符串的操作,nginx也提供了一系列的操作函数,定义在nginx_string.[c|h]中:
#define ngx_string(str) { sizeof(str) - 1, (u_char *) str }
将它一个普通字符串转换成一个nginx字符串格式,如
ngx_str_t name = ngx_string(“http”); // 注意name是结构体,而不是指针,宏预处理后等价于
ngx_str_t name = {sizeof(“http”)-1, (u_char*)”http”};

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了nginx自定义字符串,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
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
Latest Issues
Error restarting nginx
From 1970-01-01 08:00:00
0
0
0
server - Nginx configuration webapp problem
From 1970-01-01 08:00:00
0
0
0
Nginx default.conf problem
From 1970-01-01 08:00:00
0
0
0
centos7 - NGINX exception occurs
From 1970-01-01 08:00:00
0
0
0
nginx load balancing
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template