Ver Mensaje Individual
  #5 (permalink)  
Antiguo 19/08/2005, 23:49
Avatar de adriancid
adriancid
 
Fecha de Ingreso: abril-2005
Ubicación: Versalles, Santiago de Cuba, Cuba
Mensajes: 53
Antigüedad: 19 años, 1 mes
Puntos: 0
Código PHP:
<?php 
// Declaracion de una clase simple 
class ClaseTest 

   public 
$foo

   public function 
__construct($foo) { 
       
$this->foo $foo
   } 

   public function 
__toString() { 
       return 
$this->foo
   } 


$clase = new ClaseTest('Hola'); 
echo 
"Mi nombre es: " $clase
?>
Si hubieras leido el manual habrias leido algo parecido a esto

Código PHP:
<?php
// __toString called
echo $class;

// __toString called (still a normal parameter for echo)
echo 'text'$class;

// __toString not called (concatenation operator used first)
echo 'text' $class;

// __toString not called (cast to string first)
echo (string) $class;

// __toString not called (cast to string first)
echo "text $class";
?>

Última edición por adriancid; 19/08/2005 a las 23:56