Re: str_replace does not like empty quotes [message #186204 is a reply to message #186191] |
Fri, 20 June 2014 07:31 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
[Cancel & Supersedes]
Lew Pitcher wrote:
> On Thursday 19 June 2014 19:33, in comp.lang.php, "richard"
> <noreply(at)example(dot)com> wrote:
It is called attribution *line*, _not_ attribution novel.
>> $a=str_replace($a,"\","");
'---'
>> This generates the error: Unexpected "".
The *actual* error message is
,----
| $ php -r '$a=str_replace($a,"\","");'
| PHP Parse error: syntax error, unexpected '"' in Command line code on
^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^
| line 1
`----
with
,----
| $ php -v
| PHP 5.6.0beta4 (cli) (built: Jun 10 2014 16:51:46)
| Copyright (c) 1997-2014 The PHP Group
| Zend Engine v2.6.0-dev, Copyright (c) 1998-2014 Zend Technologies
| with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend
| Technologies
| with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans
`----
Note the *single-quoted* double-quote in the error message.
> Of course it does. You are trying to replace all the strings that match $a
> with "\" in an empty string ("").
No, he does not. The *main* error here is a *syntax* error. I have marked
the string literal in the statement above (as always, use a fixed-width
font), so that you can see the trailing <"> better.
Note the *escaped* double-quote in the string literal. Note where the
string literal starts and where it therefore ends, which syntax-highlighting
shows in any decent PHP editor (such as Eclipse PDT).
PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
|
|
|