<php学习>简单高效的php内置函数(二)

发布于:2023-03-27 ⋅ 阅读:(228) ⋅ 点赞:(0)
  • 1.返回由对象属性组成的关联数组
array get_object_vars( object $obj)
  • 2.返回一个常量的值使用函数 constant
define("MAXSIZE", 100);
echo MAXSIZE;
echo constant("MAXSIZE"); // same thing as the previous line
interface bar {
    const test = 'foobar!';
}
class foo {
    const test = 'foobar!';
}
$const = 'test';
var_dump(constant('bar::'. $const)); // string(7) "foobar!"
var_dump(constant('foo::'. $const)); // string(7) "foobar!"
  • 3.将一个或多个单元压入数组的末尾(入栈)
array array_push ( array $array , mixed $var [, mixed $... ] )
  • 4.在 haystack 中搜索 needle,如果没有设置 strict 则使用宽松的比较。若 strict 的值为 TRUE 则 in_array() 函数还会检查 needle 的类型是否和 haystack 中的相同。
bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )