#extract
PHP extract() 函数从数组中把变量导入到当前的符号表中。
<?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
#set_time_limit:
运行后会在运行文件的同级目录生成如:1.txt、2.txt、3.txt等文件,直到点击 stop 生成 stop.txt后才停止。
<?php
set_time_limit(0); //作为无限制脚本
echo '<a href="?stop=1">STOP</a>';
if (isset($_GET['stop'])){
$filename = "stop.txt";
fopen($filename, "w");
}
$b = true;
$i = 0;
do{
$i ++;
$filename = $i . ".txt";
$stopfile = "stop.txt";
if (file_exists($stopfile)){
exit();
}
@fopen($filename, ‘w’);
@file_put_contents($filename, $i);
sleep(3);
} while ($b);
?>
#compact
<?php
$firstname = "phpbox.cn";
$lastname = "tong";
$age = "38";
$result = compact("firstname", "lastname", "age");
echo "<pre>";
print_r($result);
?>
运行结果:Array
(
[firstname] => phpbox.cn
[lastname] => tong
[age] => 38
)
#http_build_query
<?php
$data = array(
'domain'=>'www.phpbox.cn',
'site'=>'phpbox',
'name'=>'feige'
);
echo http_build_query($data);
?>
运行结果:domain=www.phpbox.cn&site=phpbox&name=feige