0

I'm trying to pass a username with domain in PHP, and am having issues with backslashes either being completely stripped or "doubled up". I've tried a ton of different fixes, and nothing is working.

$domain = "domain";
$username = "username";
$adfs = stripslashes($domain.'\\'.$username);
$dynamicsClient = new dynamicsClient($adfs, $password, $URL, 1);

What I want as the end result is domain\username.

Seems simple enough, but because of escaping, I can't get this to work. I'm new to PHP, so there must be a fix.

Please help.

3
  • just remove stripslashes() Commented Dec 11, 2014 at 17:26
  • what wrong with $domain.'\\'.$username? Commented Dec 11, 2014 at 17:27
  • I did that, and I end up with domain\\username. It doubles up. :( Commented Dec 11, 2014 at 17:37

2 Answers 2

2

This should work for you:

$domain = "domain";
$username = "username";
$adfs = $domain.'\\'.$username;
Sign up to request clarification or add additional context in comments.

6 Comments

I did that, and I end up with domain\\username. It doubles up. :(
@Mayhem Did you used echo or where do you use it?
I'm passing it to a function:
@Mayhem Please update your question with the function so we can see how you use it!
$dynamicsClient = new dynamicsClient($adfs, $password, $URL, 1); If I use $adfs = stripslashes($domain.'\\'.$username);, I get no slashes. If I use $adfs = $domain.'\\'.$username; I get two slashes.
|
1

You are stripping the slash that you've properly escaped. Change:

 $adfs = stripslashes($domain.'\\'.$username);

To:

 $adfs = $domain.'\\'.$username;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.