定义和用法
PHP extract() 函数从数组中把变量导入到当前的符号表中。
对于数组中的每个元素,键名用于变量名,键值用于变量值。
第二个参数 type 用于指定当某个变量已经存在,而数组中又有同名元素时,extract() 函数如何对待这样的冲突。
本函数返回成功设置的变量数目。
语法
extract(array,extract_rules,prefix)
例子 1
<?php $a = 'Original'; $my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse"); extract($my_array); echo "\$a = $a; \$b = $b; \$c = $c"; ?>输出:
$a = Cat; $b = Dog; $c = Horse----------------------------------------------------------------------------------------------------描述array token_get_all ( string $source ) 阵列 token_get_all( 字符串 $源 )token_get_all() parses the given source string into PHP language tokens using the Zend engine's lexical scanner. token_get_all()解析成PHP语言定源字符串标记使用Zend引擎的词汇扫描仪。
例子1 token_get_all()例子
DE> <?php
$tokens = token_get_all ( '<?php echo; ?>' ); /* => array(
array(T_OPEN_TAG, '<?php'),
array(T_ECHO, 'echo'),
';',
array(T_CLOSE_TAG, '?>') ); */
/* Note in the following example that the string is parsed as T_INLINE_HTML
rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).
This is because no open/close tags were used in the "code" provided.
This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */
$tokens = token_get_all ( '/* comment */' ); // => array(array(T_INLINE_HTML, '/* comment */'));
?>DE>