PHP
downloads | documentation | faq | getting help | mailing lists | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

debug_zval_dump> <urlencode
Last updated: Sun, 25 Nov 2007

view this page in

Variable 变量函数

简介

有关变量行为方式的信息请查看本手册语言参考部分的变量条目。

需求

要编译本扩展模块无需外部库文件。

安装

本扩展模块作为 PHP 内核的一部分,无需安装即可使用。

运行时配置

这些函数的行为受 php.ini 的影响。

变量配置选项
名称 默认值 可修改范围 更新记录
unserialize_callback_func NULL PHP_INI_ALL 自 PHP 4.2.0 起可用。
有关 PHP_INI_* 常量进一步的细节与定义参见php.ini 配置选项

以下是配置选项的简要解释。

unserialize_callback_func string

如果解串行器发现有未定义类要被实例化,将会调用 unserialize() 回调函数(用该未定义类名作为参数)。如果指定函数不存在,或者此函数没有包含/实现该未定义类,则显示警告。所以仅在确实需要实现这样的回调函数时才设置该选项。

参见 unserialize()

资源类型

本扩展模块未定义任何资源类型。

预定义常量

本扩展模块未定义任何常量。

Table of Contents

  • debug_zval_dump — Dumps a string representation of an internal zend value to output
  • doubleval — floatval 的别名
  • empty — 检查一个变量是否为空
  • floatval — 获取变量的浮点值
  • get_defined_vars — 返回由所有已定义变量所组成的数组
  • get_resource_type — 返回资源(resource)类型
  • gettype — 获取变量的类型
  • import_request_variables — 将 GET/POST/Cookie 变量导入到全局作用域中
  • intval — 获取变量的整数值
  • is_array — 检测变量是否是数组
  • is_binary — Finds whether a variable is a native binary string
  • is_bool — 检测变量是否是布尔型
  • is_buffer — Finds whether a variable is a native unicode or binary string
  • is_callable — 检测参数是否为合法的可调用结构
  • is_double — is_float 的别名
  • is_float — 检测变量是否是浮点型
  • is_int — 检测变量是否是整数
  • is_integer — is_int 的别名
  • is_long — is_int 的别名
  • is_null — 检测变量是否为 NULL
  • is_numeric — 检测变量是否为数字或数字字符串
  • is_object — 检测变量是否是一个对象
  • is_real — is_float 的别名
  • is_resource — 检测变量是否为资源类型
  • is_scalar — 检测变量是否是一个标量
  • is_string — 检测变量是否是字符串
  • is_unicode — Finds whether a variable is a unicode string
  • isset — 检测变量是否设置
  • print_r — 打印关于变量的易于理解的信息。
  • serialize — 产生一个可存储的值的表示
  • settype — 设置变量的类型
  • strval — 获取变量的字符串值
  • unserialize — 从已存储的表示中创建 PHP 的值
  • unset — 释放给定的变量
  • var_dump — 打印变量的相关信息
  • var_export — 输出或返回一个变量的字符串表示


add a note add a note User Contributed Notes
Variables
jfrasca at sheerdev dot com
31-Aug-2005 10:27
I needed a simple function that would reduce any kind of variable to a string or number while retaining some semblance of the data that was stored in the variable. This is what I came up with:

<?
function ReduceVar ($Value) {
    switch (gettype($Value)) {
        case "boolean":
        case "integer":
        case "double":
        case "string":
        case "NULL":
            return $Value;
        case "resource":
            return get_resource_type($Value);
        case "object":
            return ReduceVar(get_object_vars($Value));
        case "array":
            if (count($Value) <= 0)
                return NULL;
            else
                return ReduceVar(reset($Value));
        default:
            return NULL;
    }
}
?>
skelley at diff dot nl
22-Sep-2001 04:55
Sorry to say Mykolas, but your definition would not be correct.

isempty() evaluates to true for NULL, 0, "", false or 'not set' for any variable, object etc. that can be set to a value.

isset() evaluates to true if the variable, object etc. exists at all, whether it is 'empty' or not.

Example:
$foo = 0;
isset($foo); //will evaluate to true.
!empty($foo); //will evaluate to false.

unset($foo);
isset($foo); //will evaluate to false.
!empty($foo); //will evaluate to false.

debug_zval_dump> <urlencode
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites