[TYPO3] Strange PHP string problem
Wiel, J.A.M van de
j.a.m.v.d.wiel at tue.nl
Thu Oct 2 13:16:53 CEST 2008
Hello all,
The past few days I've been pulling my hair out over some really strange issue. I'm trying to get some data from a web service using Nusoap (eim2nusoap) and return this to the user as a HTML table. It's a really simple price list, so nothing fancy when it comes to formatting. I'm simply cleaning up (for presentation) and concatenating some field values and markup into a single large string that forms a number of HTML tables. So far, so good and it works properly up to a point.
I'm outputting a set of three-column tables. One for a product description, one for a unit type, and one for price per unit. The cleaning up consists of replacing a '.' in the price per unit with a ',' and sticking the Euro symbol and a space in front of it if the price is a number. The principle is like this, as part of a foreach loop:
$articleTable .= '<tr><td class="article">'.$article['Description'].'</td><td>'.$article['Unit'].'</td><td class="price">'.$this->cleanUpPrice($article['Price']).'</td></tr>';
The $this->cleanUpPrice function simiply does a str_replace('.',',',$articlePrice); and concatenates itself with a euro symbol entity like $articlePrice = '€ '.$articlePrice;
This works well up to a certain point and then it fails in a very strange way. When I leave out the $articlePrice = '€ '.$articlePrice; bit, things work perfectly. When I add it, TYPO3 seems to simply skip over the entire page rendering and returns only the red 'PREVIEW' box in my browser.
What's weird about this is that I can replace the '€ ' bit with any combination of 3 regular characters and it'll work. As soon as I put more than 3 characters between the single quotes, it fails and PHP reports nothing to the error log even with error_reporting(E_ALL).
The weirdness continues though, because if I keep the cleanup stuff for the price as it should be, I can actually get a proper result but only if I remove the class attributes from the table cells. If I keep the class attributes, TYPO3 gives me the same strange behavior..
I'm beginning to suspect some kind of buffer overflow but that would be strange. I'm only outputting around 200 short table rows. Surely TYPO3 should be able to deal with that?
When I use t3lib_div::debug to give me the end result just before my plugin's main() function returns it, the string is perfectly valid (leading me to believe I'm not doing anything bad on the PHP side). It even validates perfectly when I manually paste it into a dummy page. TYPO3 appears to choke on it later though and I don't see how I should start debugging that.
Thanks for reading my long mail so far! Any help would be greatly appreciated!
Bas
More information about the TYPO3-english
mailing list