189 8069 5689

php获取数据变量名,php查看一个变量的数据类型

PHP变量名、变量值、类型

变量名 =》 zval

成都创新互联成都网站建设按需定制,是成都营销推广公司,为成都门帘提供网站建设服务,有成熟的网站定制合作流程,提供网站定制设计服务:原型图制作、网站创意设计、前端HTML5制作、后台程序开发等。成都网站制作热线:18982081108

变量值 =》zend_value

问题:

引用计数

变量传递,变量赋值

变量的基础结构

变量值:zend_value 

typedef union _zend_value {

zend_long        lval;            /* long value */

double            dval;            /* double value */

zend_refcounted  *counted;

zend_string      *str;

zend_array      *arr;

zend_object      *obj;

zend_resource    *res;

zend_reference  *ref;

zend_ast_ref    *ast;

zval            *zv;

void            *ptr;

zend_class_entry *ce;

zend_function    *func;

struct {

  uint32_t w1;

  uint32_t w2;

} ww;

} zend_value;

变量名:_zval

typedef struct _zval_struct    zval;

struct _zval_struct {

zend_value        value;        /* value */

union {

  struct {

    ZEND_ENDIAN_LOHI_4(

        zend_uchar    type,          /* active type */

        zend_uchar    type_flags,

        zend_uchar    const_flags,

        zend_uchar    reserved)        /* call info for EX(This) */

  } v;

  uint32_t type_info;

} u1;

union {

  uint32_t    var_flags;

  uint32_t    next;                /* hash collision chain */

  uint32_t    cache_slot;          /* literal cache slot */

  uint32_t    lineno;              /* line number (for ast nodes) */

  uint32_t    num_args;            /* arguments number for EX(This) */

  uint32_t    fe_pos;              /* foreach position */

  uint32_t    fe_iter_idx;          /* foreach iterator index */

} u2;

};

变量类型【type】

/* regular data types */

#define IS_UNDEF              0

#define IS_NULL                  1

#define IS_FALSE              2

#define IS_TRUE                  3

#define IS_LONG                  4

#define IS_DOUBLE              5

#define IS_STRING              6

#define IS_ARRAY              7

#define IS_OBJECT              8

#define IS_RESOURCE                9

#define IS_REFERENCE            10

/* constant expressions */

#define IS_CONSTANT                11

#define IS_CONSTANT_AST            12

/* fake types */

#define _IS_BOOL              13

#define IS_CALLABLE                14

/* internal types */

#define IS_INDIRECT                15

#define IS_PTR                17

true 和 flase 没有zend_value 结构, 直接通过type来区分,zend_long和double的变量指直接存储在_zend_value中,不需要额外的value指针。

PHP有没有办法获取变量的名称

php获取一个变量的名字的方法

这是我在网站找到的一个方法

PHP中如何获得变量名

?php

function vname($var, $scope=false, $prefix='unique', $suffix='value')

{

if($scope) $vals = $scope;

else $vals = $GLOBALS;

$old = $var;

$var = $new = $prefix.rand().$suffix;

$vname = FALSE;

foreach($vals as $key = $val) {

if($val === $new) $vname = $key;

}

$var = $old;

return $vname;

}

echo "\$变量名=".vname($变量名);

?

输出结果: $变量名=变量名


标题名称:php获取数据变量名,php查看一个变量的数据类型
当前路径:http://cdxtjz.cn/article/hsheeh.html

其他资讯