Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

proper way to strip backslashes from url

Posted on 2009-07-01
3
Medium Priority
?
314 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

609 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