public function toString()
	{
		// Reflect on class to get private or protected props
		$privateProperties = with(new \ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PROTECTED);

		// Remove each private or protected prop
		foreach ($privateProperties as $prop)
		{
			$name = (string) $prop->name;
			unset($this->$name);
		}

		// Output as json
		return json_encode($this);
	}
public function toString()
	{
		// Reflect on class to get private or protected props
		$privateProperties = with(new \ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PROTECTED);

		// Remove each private or protected prop
		foreach ($privateProperties as $prop)
		{
			$name = (string) $prop->name;
			unset($this->$name);
		}

		// Output as json
		return json_encode($this);
	}
public function toString ( ) { // Reflect on class to get private or protected props $ privateProperties = with ( new \ ReflectionClass ( $ this ) ) -> getProperties ( \ ReflectionProperty :: IS_PROTECTED ) ; // Remove each private or protected prop foreach ( $ privateProperties as $ prop ) { $ name = ( string ) $ prop -> name ; unset ( $ this -> $ name ) ; } // Output as json return json_encode ( $ this ) ; }
To String object

Removes private properties before returning

@return  string
To String object