 |
 |
Anyone knows php here?
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2000
Location: Tempe, AZ
Status:
Offline
|
|
I am stuck on the following... I would like to get some text from a user and then input that as a variable.
$a = "$input";
If the user types a word starting with a dollar sign ($), I get an error, saying that the variable does not exist... Any ideas on how to filter the dollar sign out?
Thanks,
dombi
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
|
|
|
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Jun 2001
Location: Washington DC
Status:
Offline
|
|
$a = $input; will just set a variable called $a to the same value as a variable named $input, it won't actually get the input from the user.
How are they inputing the information? Is it a web form, or just at the terminal?
If it's a web form, then the information they enter will be stored in either $_GET or $_POST depending on the submission method you're using. So if the input box was named "foo" on the web form, you would do $a = $_GET["foo"] or $a = $_POST["foo"].
If it's at the terminal... I'm not actually sure. Why would you use PHP at the terminal?
|
|
|
| |
|
|
|
 |
|
 |
|
Baninated
Join Date: Dec 2004
Location: Illinois might be cold and flat, but at least it's ugly.
Status:
Offline
|
|
Where does he mention 'terminal'?
$name = $_GET["Name"]
$name = $_POST["Name"]
Is correct, but $a is a bad variable, can't you come up with something more understandable?
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Jun 2001
Location: Washington DC
Status:
Offline
|
|
Originally Posted by budster101
Where does he mention 'terminal'?
$name = $_GET["Name"]
$name = $_POST["Name"]
Is correct, but $a is a bad variable, can't you come up with something more understandable?
He didn't say anything about the terminal, but he also didn't say anything that would make me think it was for a web page. So I figured I'd cover all the bases as best I can. As his sig says he's a web designer and PHP isn't a language that most people would choose for programming outside a web environment I wasn't too worried that I had no idea how to get input from the command line in PHP.
And $a was his variable name not mine. I was just using his example.
|
|
|
| |
|
|
|
 |
|
 |
|
Baninated
Join Date: Dec 2004
Location: Illinois might be cold and flat, but at least it's ugly.
Status:
Offline
|
|
I know about the variable name, I think I should have been clearer in my response, and I actually was directing it towards him. Sorry for the confusion, I was not critiquing your code.
Right about the web / php... conclusion.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
Yeah - the lounge - *great* place to post PHP questions.
The webDev forum must be for posting stories about badgers and things.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status:
Offline
|
|
Better than what's usually posted in the lounge.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
And amazingly, this thread has yet to see any use of the "Ha! Ha!" picture.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
Um.. original question is:
"If the user types a word starting with a dollar sign ($), I get an error, saying that the variable does not exist... Any ideas on how to filter the dollar sign out?"
Not how you read in the user's input.
|
|
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
If the question was how to you get the user input, then I would have to ask how is the user inputting data.
Is the coming from command line?
From a web form? GET or POST method?
What's for form field name?
Is global variables turned on?
|
|
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Location: Probably some pub in Reykjavik
Status:
Offline
|
|
BAH!
Use WebObjects, it's free now. And drag'n'drop is just so much more fun
(I know - not much help, but one has to spread the good word, right?)
(Last edited by Hugi; Jul 26, 2005 at 06:26 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Apr 2002
Location: Illinois
Status:
Offline
|
|
well, there is always the good ol eregi_replace...
eregi_replace("\$", "", $input);
not sure if that's gonna do it for you, but it should.
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Jun 2001
Location: Washington DC
Status:
Offline
|
|
Originally Posted by budster101
I know about the variable name, I think I should have been clearer in my response, and I actually was directing it towards him. Sorry for the confusion, I was not critiquing your code.
Right about the web / php... conclusion.
Ah, whoops. Sorry bout that. 
|
|
|
| |
|
|
|
 |
|
 |
|
Baninated
Join Date: Dec 2004
Location: Illinois might be cold and flat, but at least it's ugly.
Status:
Offline
|
|
That's cool. A lot of us are not very quick these days, and I've missed a few admittedly and have had to have a bit of crow myself.

|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|