note 76054 deleted from language.oop5.magic by tularis
| From: | tularis@php.net | Date: | Thu, 28 Jun 2007 07:03:21 +0000 |
| Subject: | note 76054 deleted from language.oop5.magic by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128042@lists.php.net to get a copy of this message | ||
Note Submitter: mark_sal
Reason: non-english
----
un caso en donde se trata de imprimir un objeto con valores array, atraves del método echo.
<?php
class TestClass
{
public $foo = array();
public function funcion_ejemplo($foo) {
$this->foo = $foo;
}
public function __toString() {
if(!is_array($this->foo)){
return $this->foo;
}
else {
print_r($this->foo);
return '';
}
}
}
$class = new TestClass();
$class->funcion_ejemplo( array( '0', '1', '2', '3',
'4', '5' ,'6' ) );
echo $class;
?>