Essentially I'm making a PHP script using php, but I can't define variables.
If I try:
It won't work... I think I've tried just about everything.Code:$phpcode .= "html_entity_decode("$")myvar = \"test\"";
Any ideas?
Essentially I'm making a PHP script using php, but I can't define variables.
If I try:
It won't work... I think I've tried just about everything.Code:$phpcode .= "html_entity_decode("$")myvar = \"test\"";
Any ideas?
- Mike
Stupid question:
how about this?Code:$phpcode .= "\$myvar = \"test\"";
I'd think there are some problems with using a function within quotes like that.
Usually, I'd go with:
func(...)."something"
etc.
The dollar sign is by default slashed, I believe, within a thread, to prevent problems. There is likely a way around this.
Are you later using the eval() function?
If you can tell us the purpose, we can figure it out more. From what you posted, I truly see no point in it... just type the literal line. But there must be some reason beyond that for using it.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Haha... you know what else is stupid ItsMeOnly? That your stupid solution doesn't work.
- Mike
In my opinoin no real question is stupid (as long as it is an actual question and not a spammer trying to make posts). I'm not sure what it is you are trying to accomplish here. Maybe some more insite would help.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
I actually have the problem solved now. I stored the "$" sign in a variable and called it later. Using it outside the string keeps it from being read as a variable which already exists. If said variable doesn't exist it will appear blank, and that was the error I was getting.
- Mike
Well, because PHP automatically parses anything in double quotes(" & "), you need to use single quotes.
PHP Code:$some_value = 'some random string';
$php_code = '$some_var = "'.$some_value.'"';
Point taken, thanks Brady. This is what I did though:
Code:$dsign = "$"; $phpcode = $dsign."query = \"mysql query...\"";
- Mike
That works, or the single quote solution is easy.
Also, ItsMeOnly's phrasing wasn't great, but it wasn't an insult to you. He meant HIS question was stupid (asking if it would work), not that yours was.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
I must say that, as is usual with eval(), there's probably a better way to accomplish whatever it is you're trying to do.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks