RE: [PHP] trim() is very strange inside a class...
| From: | Maxim Maletsky | Date: | Mon, 11 Sep 2000 10:47:18 +0000 |
| Subject: | RE: [PHP] trim() is very strange inside a class... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16149@lists.php.net to get a copy of this message | ||
Sorry for confusion Guys, you're very kind to answere me..
I found what was wrong:
you cannot use any addslashes() (or htmlentities()) before you use trim, ..
apparently when you do it there's something added to the end of the string
and so it cannot be shrinked...
On PHP4 you should use trim before you do anything with the string ... I
guess..
Thanx!
-----Original Message-----
From: Maxim Maletsky
Sent: Monday, September 11, 2000 7:39 PM
To: Maxim Maletsky
Cc: PHP General List. (E-mail)
Subject: RE: [PHP] trim() is very strange inside a class...
Sorry, I made a mistake while copying the code ...
the "second" line is not $data =nl2br(trim($data)); echo $data.'2';
but
$data =nl2br($data); echo $data.'2';
-----Original Message-----
From: Maxim Maletsky
Sent: Monday, September 11, 2000 7:37 PM
To: 'Lars Torben Wilson'
Cc: PHP General List. (E-mail)
Subject: RE: [PHP] trim() is very strange inside a class...
Yeah, sure...
here I cut&paste some of the code ...
(it's a custom build newLine-to-<P> replacer,.,)
class max_Organizer {
var $ws=" \r\n\t\v\010\013\015";
function HTML($data) {
$data =trim($data); echo $data.'1'; //this is where it
doesn't work .. //echo $data is for my tests...
$data =nl2br(trim($data)); echo $data.'2';
$data =eregi_replace("[$this->ws]*<br>[$this->ws]*",
"<BR>\n",
$data); echo $data.'3';
$data =ereg_replace("<BR>[$this->ws(<BR>)]*<BR>[$this->ws]*",
"\n\n<P>", $data); echo $data.'4';
return $data;
}
......
}
// this is a 100% identic code, which works well when called not as a
class...
$ws=" \r\n\t\v\010\013\015";
$data =eregi_replace("[$ws]*<br>[$ws]*", "<BR>\n",
nl2br(trim($data)));
$data =ereg_replace("<BR>[$ws(<BR>)]*<BR>[$ws]*",
"\n\n<P>", $data);
Try to play with it, and you'll see that something is wrong ...
-----Original Message-----
From: Lars Torben Wilson [mailto:torben@pinc.com]
Sent: Monday, September 11, 2000 7:19 PM
To: Maxim Maletsky
Cc: PHP General List. (E-mail)
Subject: Re: [PHP] trim() is very strange inside a class...
Maxim Maletsky writes:
> Hello,
>
> I was developing a function and there was a trim().
> after I saw that my faction became too big, I created a class, using same
> codes.
>
> Now, the funny thing is that trim() doesn't work properly anymore when it
> ended up inside a class...
> it still filters the beginning of the string but forgets about the end of
> it..
> I swear, I didn't touch that line (or whatever could ever affect it) at
all
> while making the class from my code...
>
> What could it be, guys?
> Have any of you had a similar problem?
>
> any suggestions?
>
> Thank you.
Can you show us some code?
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net