[colug-432] PHP 7.0.2 method wierd
Vince Herried
Vince at PlanetVince.com
Sat Jan 23 13:34:46 EST 2016
I have a class with
private $tableStr = '';
.
.
function display() {
// get colgroups/cols
$this->tableStr .= $this->getColgroups();
// get sections and their rows/cells
$this->tableStr .= !empty($this->thead)?
$this->getSection($this->thead, 'thead'): '';
$this->tableStr .= !empty($this->tfoot)?
$this->getSection($this->tfoot, 'tfoot'): '';
foreach( $this->tbody_ar as $sec ) {
$this->tableStr .= !empty($sec)? $this->getSection($sec,
'tbody'): '';
}
$this->tableStr .= "</table>\n";
return $this->tableStr;
}
in my main line code I want to save this into a file
so
<?php
$tbl = new .....
blah
blah
.
$fp = fopen('data.txt', 'w');
$str=$tbl->display();
fwrite($fp, $str);
fclose($fp);
What happens is the file gets created, and written in to
and !! the text also appears in my browser stream
If I delete the line $str=$tbl->display();
all is good, it is almost like the method had
echo $this->tableStr;
How is the
return $this->tableStr;
outputting my string to my browser ?
In another spot in my code I have
echo $tbl -> display();
and it works as expected.
I want to both display the data on the web page, and also use it
to create a pdf or .jpg file which is why I added the write function.
-
V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20160123/94f0819a/attachment.html
More information about the colug-432
mailing list