Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14475
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Matthew Carter <m@ahungry.com> |
| Newsgroups | comp.lang.php |
| Subject | Re: Purpose for a str_replace with an embedded print_r return |
| Date | Wed, 05 Nov 2014 15:50:39 -0500 |
| Organization | Ahungry (http://ahungry.com) |
| Lines | 68 |
| Message-ID | <87a945z80w.fsf@ahungry.com> (permalink) |
| References | <bad4f2c1-102e-4115-94ea-c8f8efdaca0b@googlegroups.com> <m3aq5j$hii$1@solani.org> <064143e2-28d1-40e4-a76e-c6d28b05dddb@googlegroups.com> <2023723.LoZblivUAB@PointedEars.de> <m3b44i$n5h$1@solani.org> <m3b7dm$776$1@dont-email.me> <45658857.s58lGopVbh@PointedEars.de> <m3d9mi$v4o$1@dont-email.me> <1780873.BENQMAGEWm@PointedEars.de> <m3dgkb$u89$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="7c986cd4736462de309a749b207746fe"; logging-data="15993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NaZmgbZ0c5ED/iT5CSJyJ" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:Xp25YiJUpm8Li2hxvYzr0mdvAwU= sha1:GJHwANeISvkK5CjW2dLYoBEJRuA= |
| Xref | csiph.com comp.lang.php:14475 |
Show key headers only | View raw
Jerry Stuckle <jstucklex@attglobal.net> writes:
> On 11/5/2014 9:32 AM, the pedantic troll Thomas 'Pointed Head' Lahn wrote:
>> Jerry Stuckle wrote:
>>
>>> [abuse] Thomas 'Pointed Head' Lahn wrote:
>>>> Jerry Stuckle wrote:
>>>>> On 11/4/2014 12:58 PM, Christoph M. Becker wrote:
>>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>> I think the proper idiom is “to kill two birds with one stone”. This
>>>>>>> appears to be debug code, and if you pass “true” as second parameter
>>>>>>> to print_r(), it returns the output instead of printing it.
>>>>>>
>>>>>> Good catch! At least a plausible explanation for the strange construct.
>>>>>> […]
>>>>> No, the OP already indicated the value was a simple string, not an array
>>>>> or object reference, so the print_r() is unnecessary (and potentially
>>>>> confusing).
>>>> Which part of “debug code” did you not understand?
>>>
>>> Which part of "unnecessary code" did you not understand?
>>
>> It is unnecessary only *in your humble opinion*. However, in *debug* code
>> one wants to have a contingency plan. One does not want to get the string
>> representation of a non-string value when you can inspect the unusual array
>> or object instead.
>>
>>> [abuse]
>>
>> Just go away.
>>
>>
>
> This is why you're so stoopid. The variable being debugged is a STRING
> - as the OP said. It's not an array. It's not an object. It's a
> STRING. But you don't understand the difference.
>
> Yes, please go away. Pedantic trolls like you are not welcome here.
>
> And on the way out, don't let the door hit you in the butt. You might
> get a brain concussion.
I did a quick test and there is a difference between using a plain
string and a string wrapped in print_r when you store a
an invalid character in the string and run the script via mod_php.
Try the following snippet:
<?php
header('Content-type: text/html; charset=utf-8');
$string = chr(980); // Some garbage
echo 'The echo: '.$string;
echo 'The print_r: '.print_r($string, TRUE);
?>
You will notice that the character is not sent to the browser when
passed through print_r (it is via the CLI though, so not sure if this is
a mod_php feature).
Changing the encoding to ISO will pass it in both cases (as it is a
valid character in that set).
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Purpose for a str_replace with an embedded print_r return Dave Patoch <earthlydilemma@gmail.com> - 2014-11-04 06:20 -0800
Re: Purpose for a str_replace with an embedded print_r return "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-04 16:08 +0100
Re: Purpose for a str_replace with an embedded print_r return Dave Patoch <earthlydilemma@gmail.com> - 2014-11-04 07:27 -0800
Re: Purpose for a str_replace with an embedded print_r return Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-04 16:58 +0100
Re: Purpose for a str_replace with an embedded print_r return "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-04 18:58 +0100
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-04 13:54 -0500
Re: Purpose for a str_replace with an embedded print_r return Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-05 14:27 +0100
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 08:46 -0500
Re: Purpose for a str_replace with an embedded print_r return Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-05 15:32 +0100
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 10:44 -0500
Re: Purpose for a str_replace with an embedded print_r return Matthew Carter <m@ahungry.com> - 2014-11-05 15:50 -0500
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 16:59 -0500
Re: Purpose for a str_replace with an embedded print_r return "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-05 23:56 +0100
Re: Purpose for a str_replace with an embedded print_r return Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-06 04:30 +0100
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 22:53 -0500
Re: Purpose for a str_replace with an embedded print_r return Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-05 15:07 +0000
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 10:47 -0500
Re: Purpose for a str_replace with an embedded print_r return Matthew Carter <m@ahungry.com> - 2014-11-05 15:51 -0500
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 17:00 -0500
Re: Purpose for a str_replace with an embedded print_r return Matthew Carter <m@ahungry.com> - 2014-11-05 22:35 -0500
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 22:55 -0500
Re: Purpose for a str_replace with an embedded print_r return Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-06 04:26 +0000
Re: Purpose for a str_replace with an embedded print_r return Matthew Carter <m@ahungry.com> - 2014-11-06 00:09 -0500
Re: Purpose for a str_replace with an embedded print_r return Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-06 23:59 +0000
Re: Purpose for a str_replace with an embedded print_r return "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-06 18:43 +0100
Re: Purpose for a str_replace with an embedded print_r return Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-06 02:39 +0000
Re: Purpose for a str_replace with an embedded print_r return Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-06 02:44 +0000
Re: Purpose for a str_replace with an embedded print_r return Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 22:56 -0500
csiph-web