note 36296 rejected from reserved.variables by pollita
| From: | pollita@php.net | Date: | Sat, 04 Oct 2003 00:57:48 +0000 |
| Subject: | note 36296 rejected from reserved.variables by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57791@lists.php.net to get a copy of this message | ||
Note Submitter: bill@flyingguy.com
----
I am teaching myself php and am once again disapointed in a language and its documentation.
<sigh> Just trying to get the basics down like fetching arguments from the command line and
its utterly inscrutable!!!
$_GET seems to be the correct predefined global variable for fetching the command line. It is
defined as a global variable, and yet in actuality it is a function?!?
getvars.php?abc
This <?php echo $_GET ?> yields "Array"...
This <?php echo $_GET[1] yields nothing
Yet....
getvars.php?abc=1
This <?php echo $_GET['abc'] ?> yields "1"
Clearly this is not a variable, it is a function. When something takes a parameter and returns a
value its a function, variables do NOT do this in ANY language.
I have also not yet deternined how to call a php script [program] with multiple vars on the command
line, or even know how many there are!
Can someone please help me out here?
Is there some like argc or args that is equivilent to C or something like ParamCount() in Pascal ?
I mean is C it would be :
void main(*char args, int argc)
{
int i ;
for(i=1,i=argc,i++)
{
printf('Argument %i is %s ',i,args[i])
}
}
Or in pascal it would be
procedure Main ;
var
x : integer
begin
for x := 1 to ParamCount do writeln(ParamStr(x));
end;
Thanks in advance.