Accessing global variables $ _ post, $ _ get, and $ _ server in PHP Extension

Source: Internet
Author: User

Write extension, unable to access global variables such as $ _ post, $ _ Get, $ _ server, etc,

 

The following are provided by yaf:Code, I removed the yaf-related macros...

 1 /** Yaf documentationHttp://yaf.laruence.com/manual/**/

2
3
4 Zval * yaf_request_query ( Uint Type, Char * Name, Uint Len tsrmls_dc ){
5 Zval ** carrier, ** ret;
6
7 # If (Php_major_version = 5) & (php_minor_version <4)
8 Zend_bool jit_initialization = (PG (auto_globals_jit )&&! PG (register_globals )&&! PG (register_long_arrays ));
9 # Else
10 Zend_bool jit_initialization = PG (auto_globals_jit );
11 # Endif
12
13 /* For phpunit test requirements */
14 Switch (Type ){
15 Case Track_vars_post:
16 Case Track_vars_get:
17 Case Track_vars_files:
18 Case Track_vars_cookie:
19 Carrier = & PG (http_globals) [type];
20 Break ;
21 Case Track_vars_env:
22 If (Jit_initialization ){
23 Zend_is_auto_global (zend_strl ( " _ Env " ) Tsrmls_cc );
24 }
25 Carrier = & PG (http_globals) [type];
26 Break ;
27 Case Track_vars_server:
28 If (Jit_initialization ){
29 Zend_is_auto_global (zend_strl ( " _ Server " ) Tsrmls_cc );
30 }
31 Carrier = & PG (http_globals) [type];
32 Break ;
33 Case Track_vars_request:
34 If (Jit_initialization ){
35 Zend_is_auto_global (zend_strl ( " _ Request " ) Tsrmls_cc );
36 }
37 ( Void ) Zend_hash_find (& EG (symbol_table ), " _ Request " , Sizeof ( " _ Request " )- 1 ,( Void **) & Carrier );
38 Break ;
39 Default :
40 Break ;
41 }
42
43 If (! Carrier |! (* Carrier )){
44 Zval * empty;
45 Make_std_zval (empty );
46 Zval_null (empty );
47 Return Empty;
48 }
49
50 If (! Len ){
51 Z_addref_p (* carrier );
52 Return * Carrier;
53 }
54
55 If (Zend_hash_find (z_arrval_pp (carrier), name, Len + 1 ,( Void **) & RET) = failure ){
56 Zval * empty;
57 Make_std_zval (empty );
58 Zval_null (empty );
59 Return Empty;
60 }
61
62 Z_addref_p (* RET );
63 Return * Ret;
64 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.