今天看一段代码,发现var_dump($array),查了下,和print_r类型差不多,都是把一个array里的value都写出来。不过也有稍微不同的地方:var_dump会显示一个array 的数据类型和结构,而print_r只告诉你array里的值是多少。对于一个print_r主要用来testing和debugging的开发人员来说,var_dump似乎更有用一点。

Example:

[php]$obj = (object) array(‘qualitypoint’, ‘technologies’, ‘India’);[/php]

var_dump($obj) will display below output in the screen.

[php]
object(stdClass)#1 (3) {
[0]=> string(12) "qualitypoint"
[1]=> string(12) "technologies"
[2]=> string(5) "India"
}
[/php]

And, print_r($obj) will display below output in the screen.

[php]stdClass Object (
[0] => qualitypoint
[1] => technologies
[2] => India
)
[/php]

Advertisements
Posted in PHP

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s