From 9474b3eb0dc6e691769303ebebafa635e1638ced Mon Sep 17 00:00:00 2001 From: Brandon Frohs Date: Tue, 17 Jul 2012 11:21:35 -0300 Subject: [PATCH] Allow `$diff = new FineDiff($from, $to);echo $diff;` --- finediff.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/finediff.php b/finediff.php index 2e38b77..991ed72 100644 --- a/finediff.php +++ b/finediff.php @@ -220,6 +220,15 @@ public function __construct($from_text = '', $to_text = '', $granularityStack = $this->doDiff($from_text, $to_text); } + /** + * Magic __toString() method + * ... + * Assuming `$diff = new FineDiff($from, $to);`, `echo $diff` will print the HTML diff. + */ + public function __toString(){ + return $this->renderDiffToHTML(); + } + public function getOps() { return $this->edits; }