当我使用智能::在Perl评论,我能看到的哈希的名字我倾倒(即%的人,下同)。 。 。什么PHP函数将打印一个数组的名称及其内容?
[[email protected] ~]$ cat /tmp/person.pl
#!/usr/bin/perl
use strict;
use warnings;
use Smart::Comments;
my %person = (
'hair' => 'golden',
'eyes' => 'blue',
);
### %person
[[email protected] ~]$ perl /tmp/person.pl
### %person: {
### eyes => 'blue',
### hair => 'golden'
### }
[[email protected] ~]$
。 。 。但在PHP中,我只看到“Array”,没有提及$ person。 。 。
[[email protected] ~]$ cat /tmp/person.php
<?php
$person = array(
'hair' => 'golden',
'eyes' => 'blue',
);
print_r($person);
[[email protected] ~]$ php /tmp/person.php
Array
(
[hair] => golden
[eyes] => blue
)
[[email protected] ~]$
我试过print_r()
,var_export()
,并var_dump()
但有一些其他的PHP函数,将打印其内容的数组的名字吗?
确认,打我给它。还有一个更好的例子。 +1。 – NateDSaint 2009-09-24 17:16:16
我认为通过函数的'返回'路径缺少varName和print_r()之间的冒号。好例子。 +1。 – drewm 2009-09-24 18:52:14