CodeIgniter Forums
Word Wrap - Fatal Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Word Wrap - Fatal Error (/showthread.php?tid=4293)



Word Wrap - Fatal Error - El Forum - 11-16-2007

[eluser]Phil Sturgeon[/eluser]
Was using word_wrap and got a strange error:

Quote:Fatal error: Using $this when not in object context in P:\Web Sites\kicknote\system\helpers\text_helper.php on line 395

Downloaded a fresh version of the text helper just to make sure it wasnt destroyed during some of my awesome 'Find & Replace Coding' and its in there too...

Code:
// If $temp contains data it means we had to split up an over-length
        // word into smaller chunks so we'll add it back to our current line
        if ($temp != '')
        {
            $output .= $temp.$this->newline.$line;
        }
        else
        {
            $output .= $line;
        }

I cant seem to work out what the hell $this->newline is doing there. Its causing an error and I can see no reason why it should be there. $newline doesnt exist, $this isnt declared, its not in a function... what in the hell?


Word Wrap - Fatal Error - El Forum - 11-16-2007

[eluser]Michael Wales[/eluser]
I checked the SVN version - same issue.

Submit a bug in the bug tracker?


Word Wrap - Fatal Error - El Forum - 11-16-2007

[eluser]Michael Wales[/eluser]
Without testing and just looking over the code - I think changing line 395 as follows will fix the issue:

Code:
if ($temp != '')
{
    $output .= $temp.'\n'.$line;
}
else
{
    $output .= $line;
}



Word Wrap - Fatal Error - El Forum - 11-16-2007

[eluser]Seppo[/eluser]
Use doble quotes instead of single quotes for \n... otherwise you will actually print a literal \n


Word Wrap - Fatal Error - El Forum - 11-29-2007

[eluser]terminate[/eluser]
Thank you for your help guys! Had the exact same problem. Fixed it like you said.

Replace line 395 on text_helper.php
Code:
$output .= $temp.$this->newline.$line;

For
Code:
$output .= $temp."\n".$line;



Word Wrap - Fatal Error - El Forum - 11-29-2007

[eluser]Derek Allard[/eluser]
Ah. I can explain how that got in there... but I'll instead just say "fixed".