Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10693 > unrolled thread

PHP wirdwrap()

Started byTwayne <nobody@spamcop.net>
First post2013-09-01 12:30 -0400
Last post2013-09-02 12:33 -0400
Articles 3 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  PHP wirdwrap() Twayne <nobody@spamcop.net> - 2013-09-01 12:30 -0400
    Re: PHP wirdwrap() Fiver <numeralfive@gmail.com> - 2013-09-01 19:48 +0200
      Re: PHP wirdwrap() Twayne <nobody@spamcop.net> - 2013-09-02 12:33 -0400

#10693 — PHP wirdwrap()

FromTwayne <nobody@spamcop.net>
Date2013-09-01 12:30 -0400
SubjectPHP wirdwrap()
Message-ID<kvvq3p$eac$1@speranza.aioe.org>
Hi all,

I'm looking for verification (or the opposite) of the following things 
about the PHP wordwrap() function:

This code works first time, every time:

<code>
$comments = $_POST["comments"];
echo $comments . "<br /><br />";
echo wordwrap($comments,40,"<br>");
</quote>

but this code always fails to do anything to the variable: it remains 
exactly as the raw data was:

<code>
$comments = $_POST["comments"];
echo $comments . "<br /><br />";
$comments =  wordwrap($comments,40,"<br>");
echo $comments . "<br /><br />";
</quote>

The display from both echo statements are identical in the above script; 
no wrap and no errors, notices or warnings.

The manual, W3schools, et al all show examples that only use the "echo" 
statement with it as in the first code snippet above. At first I assumed 
because that was the best way to demo it, and nothing indicated the 
wordwrap output couldn't be assigned to a variable. But since it won't 
work any other way, well ... wassup up doc? :)  What have I missed?

Also, at one time, I knew of a site where one could insert code snippets 
of PHP and have them evaluated, but cannot locate it again; anyone 
happen to know of one like that?

TIA,

Twayne`










[toc] | [next] | [standalone]


#10694

FromFiver <numeralfive@gmail.com>
Date2013-09-01 19:48 +0200
Message-ID<kvvukv$oa7$1@dont-email.me>
In reply to#10693
On 2013-09-01 18:30, Twayne wrote:
> This code works first time, every time:
> 
> <code>
> $comments = $_POST["comments"];
> echo $comments . "<br /><br />";
> echo wordwrap($comments,40,"<br>");
> </quote>
> 
> but this code always fails to do anything to the variable: it remains 
> exactly as the raw data was:
> 
> <code>
> $comments = $_POST["comments"];
> echo $comments . "<br /><br />";
> $comments =  wordwrap($comments,40,"<br>");
> echo $comments . "<br /><br />";
> </quote>

You've made some error in your tests. Both will print the exact same thing.

By the way:
- <code></quote>?
- <br /> or <br>?

> Also, at one time, I knew of a site where one could insert code snippets 
> of PHP and have them evaluated, but cannot locate it again; anyone 
> happen to know of one like that?

http://sandbox.onlinephpfunctions.com/

regards,
5er

[toc] | [prev] | [next] | [standalone]


#10704

FromTwayne <nobody@spamcop.net>
Date2013-09-02 12:33 -0400
Message-ID<l02ekb$bd3$1@speranza.aioe.org>
In reply to#10694
On 2013-09-01 1:48 PM, Fiver wrote:
> On 2013-09-01 18:30, Twayne wrote:
>> This code works first time, every time:
>>
>> <code>
>> $comments = $_POST["comments"];
>> echo $comments . "<br /><br />";
>> echo wordwrap($comments,40,"<br>");  <------ comma before the "<br>") instead of period!  Dumb!!
>> </quote>
>>
>> but this code always fails to do anything to the variable: it remains
>> exactly as the raw data was:
>>
>> <code>
>> $comments = $_POST["comments"];
>> echo $comments . "<br /><br />";
>> $comments =  wordwrap($comments,40,"<br>");
>> echo $comments . "<br /><br />";
>> </quote>
>
> You've made some error in your tests. Both will print the exact same thing.
>
> By the way:
> - <code></quote>?
> - <br /> or <br>?

I was pretty tired when I wrote that; didn't think I could screw up 
anything so simple.  I need to quit posting when I'm not feeling good; 
and will in the future!
>
>> Also, at one time, I knew of a site where one could insert code snippets
>> of PHP and have them evaluated, but cannot locate it again; anyone
>> happen to know of one like that?
>
> http://sandbox.onlinephpfunctions.com/

Hmm, thanks!  That might help a bunch.

Thanks for your patience,

Twayne`
>
> regards,
> 5er
>


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web