?
Solved

proper way to strip backslashes from url

Posted on 2009-07-01
3
Medium Priority
?
312 Views
Last Modified: 2012-05-07
I need to know a proper, secure, and proficient way to strip not only front slashes but backslashes as well from a url.

the current code im working with is

define('DOMAIN', rtrim(rtrim($_SERVER['HTTP_HOST'], '/') . dirname($_SERVER['PHP_SELF']), '/'));

but it does not strip backslashes which might appear on wamp setups (windows systems)
0
Comment
Question by:redcable
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
kevin_u earned 2000 total points
ID: 24758998
define('DOMAIN', rtrim(rtrim($_SERVER['HTTP_HOST'], '/\\') . dirname($_SERVER['PHP_SELF']), '/\\'));


That will strip trailing / or \... but I'm not sure if thats what you wanted.
0
 

Author Comment

by:redcable
ID: 24759161
define('DOMAIN', rtrim(rtrim($_SERVER['HTTP_HOST'], '/\\') . dirname($_SERVER['PHP_SELF']), '/\\'));

ahh ok i was close. thanks any downside to doing it this way?
0
 
LVL 12

Expert Comment

by:kevin_u
ID: 24759690
I can't say there's a downside, unless I know what you are trying to accomplish.

What is DOMAIN used for in the rest of the script?

What if the PHP_SELF has back slashses embedded in it instead of just at the end?

A few examples would help me understand the question.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question