1 $firstname = "Peter"; 2 $lastname = "Griffin"; 3 $age = "41"; 4 5 $data = compact("firstname", "lastname", "age"); 6 7 print_r($data); 8 9 运行结果:Array ( [firstname] => Peter [lastname] => Griffin [age] => 41 )
创建一个包含变量名和它们的值的数组