0

Basically I'm sending a formatted string to a PHP script via POST

So say I have the string... "abcdef$ghikl" it will recognize $ghikl as a variable...

Is there any ways to tell PHP that no variables exist within this string?

I know how to hard code it, you just use "'", but since the string is being sent to the script, I don't know what to do...

Thanks guys

For the scope of the question, all the code that's really needed is this:

$string = $_POST['string'];
// a couple strcmp's here, just to see if the string == ""
$array = explode("+", $string);
1
  • Use single quote ' instead of double quotes " Commented Mar 9, 2012 at 2:04

2 Answers 2

3

Try escaping the $

"abcdef\$ghikl"
Sign up to request clarification or add additional context in comments.

5 Comments

is there an alternative? given the design of my application, that isn't a very efficient option...
If the dollar sign is in a string in a POST variable, then it will not recognize it as a variable. This only happens with string literals.
well now I'm baffled... it's weird because when I remove all the '$' from the string and send it via post, everything works great... so that has to be the problem...
Are you sending the string from javascript? If so you can just remove the dollar signs before you send it, str.replace( /\$/g, "\\$" )
yeah it's through cocoa... thanks for the help I think I'll just add slashes before all the $ signs :/
0

PHP won't see that as a variable unless you eval() it. Can you show us your code?

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.