PHP/Development/print r — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
print_r a class
<?php
class Person {
private $name;
private $age;
private $id;
function __construct( $name, $age ) {
$this->name = $name;
$this->age = $age;
}
function setId( $id ) {
$this->id = $id;
}
function __clone() {
$this->id = 0;
}
}
$person = new Person( "Joe", 44 );
$person->setId( 111 );
$person2 = clone $person;
print( $person );
print_r( $person );
print( $person2 );
print_r( $person2 );
?>
print_r for array
<?php
$languages = array ("A" => "A1",
"B" => "B1",
"C" => "C1");
print_r($languages);
?>
print_r: output associate array
<?php
$states = array (
"Ohio" => array ("population" => "11,353,140", capital => "Columbus"),
"Nebraska" => array("population" => "1,711,263", capital => "Omaha")
)
print_r($states);
?>