473,473 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What is wrong with: str_replace('\\', '\', $content);

Hi all

I have text area, where I can edit files - but I have to correct the
returned data, for that I use

$content=str_replace('\"', '"', $content);
and
$content=str_replace('\\', '\', $content);

by some reason the latter one causes an error: syntax error,
unexpected T_VARIABLE in....
Replacing :-) it by

$content=str_replace("\\\\", "\\", $content);

and it works

what is wrong with '\\' ?

WBR
Sonnich
Jan 10 '08 #1
3 2174
try
$content=str_replace("\\'", "'\'", $content);
// Anders
On 10 Jan, 09:19, jodleren <sonn...@hot.eewrote:
Hi all

I have text area, where I can edit files - but I have to correct the
returned data, for that I use

$content=str_replace('\"', '"', $content);
and
$content=str_replace('\\', '\', $content);

by some reason the latter one causes an error: syntax error,
unexpected T_VARIABLE in....
Replacing :-) it by

$content=str_replace("\\\\", "\\", $content);

and it works

what is wrong with '\\' ?

WBR
Sonnich
Jan 10 '08 #2
On Jan 10, 8:19 am, jodleren <sonn...@hot.eewrote:
Hi all

I have text area, where I can edit files - but I have to correct the
returned data, for that I use

$content=str_replace('\"', '"', $content);
and
$content=str_replace('\\', '\', $content);

by some reason the latter one causes an error: syntax error,
unexpected T_VARIABLE in....
Replacing :-) it by

$content=str_replace("\\\\", "\\", $content);

and it works

what is wrong with '\\' ?

WBR
Sonnich
It's because the backslash character is used for escaping characters
in strings, in other words telling the parser to treat the following
character as its literal value instead of the special meaning it may
have in the language. For example the ' character closes a single
quoted string, so if you want to use that character inside a string
you have to enter it as \' which basically tells the parser "Don't end
the string with this ' symbol, insert the ' character into the string
instead".

As the \ character has a sepcial meaning if you want to insert it then
you have to escape it, resulting in \\

If the intention is to remove slashes from form-submitted data (which
is what I suspect you are trying to do) then you might want to look
into using the stripslashes () function instead.
Jan 10 '08 #3
On Jan 10, 11:55*am, Gordon <gordon.mc...@ntlworld.comwrote:
On Jan 10, 8:19 am, jodleren <sonn...@hot.eewrote:

If the intention is to remove slashes from form-submitted data (which
is what I suspect you are trying to do) then you might want to look
into using the stripslashes () function instead.- Hide quoted text -
Thanks

That was what I was looking for.
Jan 10 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robbie | last post by:
I'm looking for an open-source CMS which has the concept of customizable content types and categories. It ideally needs to run on a LAMP platform. To give a specific example, part of the site I...
0
by: Arg | last post by:
I posted this to alt.comp.lang.php last week and got no response so I am reposting it here today... I am trying to use the following script to allow users to download files with some of the file...
2
by: Ohad | last post by:
Hello, I'm trying to send an email message using c#'s SmtpMail class. Everything, including attachments, is working properly. My problem is this: I need to assign a content id to one of the...
1
by: Steve Roszko | last post by:
I was using SmartNavigation="True" on a new project. Worked great....until it was out in the field where they use IE's Content Advisor. Using SmartNavigation="True" and Content Advisor enabled,...
0
by: Steven.Dahlin | last post by:
I am trying to test interoperability between Websphere/Applicaton Developer and .net using web services. I have created a web service using Websphere 5.1.2 which is called by a .net client. ...
2
by: Jerry Sievers | last post by:
A bit OT as this could pertain to perl CGIs too, etc. I have a php script that is hit, takes a file ID as GET parameter... does various checks including matching PHPSESSID to make sure the user...
0
by: ftech | last post by:
I am saving PDF files in SQL Server 2005 as an image and retrieve them back by their document ids. I use the following code: byte buffer = (byte)dtDoc.Rows; if(buffer != null) { ...
0
by: Christof Hoeke | last post by:
hi, I noticed while trying a simple (but still very useful) server based on SimpleHTTP that it does report a wrong "Content-Length" for "text/*" files if Windows line-end "\r\n" is used. Most...
0
by: robert112 | last post by:
Hi All, I have a .net WSE 3.0 Web Service acting as a client calling a j2EE web Service. The service works when I call it using a client program called soapUI (which is free to download) but when...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.