English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I remember that in BASIC, using "input" i could ask for a user input. For example,
input a,b
if a>b then print a

My question is that is there any way to do the same thing in PHP without using html forms?

2007-02-19 06:11:57 · 2 answers · asked by ? 2 in Computers & Internet Programming & Design

2 answers

It depends on how you are executing PHP itself...

1) Though a web server, using either CGI or a module.

2) From the command-line (the CLI version)

In case number 1, you get your data either from a web form, or typed directly into a URL. You then access that data via either the $_GET[] or $_POST arrays.

In case 2, your easiest solution would be to enter any variable data as parameters right after the called PHP script. The $argc variable holds the number of arguments in the array, and $argv holds the data.

If you need something more interactive on the command line, consider using the file system to open STDIN (for input) and STDOUT (for output).

2007-02-19 12:39:28 · answer #1 · answered by Anonymous · 2 1

You can't, unless you are executing your PHP in the command line (which is generally pretty pointless unless you are trying to test or debug or something). PHP is a scripting language - it simply outputs text (or some other output). It's usefulness, like any other web-oriented language, is limited to processing variables and producing formatted data - 99% of the time, in the format of HTML, to be interpreted by browsers.

2007-02-19 14:16:24 · answer #2 · answered by Rex M 6 · 0 1

fedest.com, questions and answers