哪里是像$ _GLOBAL,$ _ POST等全局变量保存在哪里? [英] Where is global variables like $_GLOBAL , $_POST etc stored?

查看:161
本文介绍了哪里是像$ _GLOBAL,$ _ POST等全局变量保存在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我参加一次采访中,面试官问我这个问题。这记忆他们使用的是堆,栈等我GOOGLE了,但我没有得到任何明确的答案。

When i attended an interview, the interviewer asked me this question. Which memory they are using heap , stack etc. I googled it but i didn't get any clear answer.

推荐答案

$ _ POST 内部的内部创建的 php_auto_globals_create_post() 并通过提供 PG(http_globals)[TRACK_VARS_POST] ,这仅仅是一个参考的 http_globals

The values of $_POST internally are created inside php_auto_globals_create_post() and made available via PG(http_globals)[TRACK_VARS_POST], which is just a way to reference http_globals.

的上述定义 http_globals 告诉我们,它的 的zval * 元素,每个 $ _ POST $ _ GET $ _ COOKIE 等。(数组也存储在的zval <内部/ code>容器)。

The definition of aforementioned http_globals tells us that it's an array of zval * elements, one for each $_POST, $_GET, $_COOKIE, etc. (arrays are also stored inside a zval container).

分配的zval 通过的 ALLOC_ZVAL() ,它调用以下功能:

Allocating a zval is done via ALLOC_ZVAL(), which calls the following functions:


  1. _emalloc()

  2. _malloc()

的malloc()函数分配内存堆,因此这个答案就是

The malloc() function allocates memory on the heap, so therefore the answer is heap.

这篇关于哪里是像$ _GLOBAL,$ _ POST等全局变量保存在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆