Click to See Complete Forum and Search --> : $_GET in scripts


wazaa
11-04-2005, 08:41 AM
Hi

Well, I have a little problem.

I like to make scripts in php more that in other programs, because changing the language of programing always carry confusions and mistakes from other languages...

Well, the problem is that for my confort, I used more the $_GET variables than the argc and argv to get the params in scripts.

For example:
./script.php -param1=blablablah -param2=eoooo

This has worked always to me, in php4, and is very confortable.

The problem is that in some of computers in our office we are biggin to put the php5, and the $_GET in scripts is not working now... I have looked the php.ini configuration but I don't see what I need to change to make this work. I have a lot of scripts that are using very people with this problem, in a few days I will update my own machine to php5, and the old way was very confortable...

Someone know if there is something in the configuration that I need to change to work in the old way, or if I'm going to have to change all my old scripts? :(

Thx!

pd: Please sorry my english... For so complex questions it's very usseles

laserlight
11-04-2005, 08:47 AM
Using the $_GET superglobal array is standard in PHP5. Could you give an example of code using $_GET that works on PHP4 but fails on PHP5?

wazaa
11-04-2005, 09:04 AM
Hi, no problem, here is a fast example:

#!/usr/bin/php -q
<?php

print_r ($_GET);

?>

In my computer, php4:
./test.php a=1 b=2 c=3
Array
(
[a] => 1
[b] => 2
[c] => 3
)

In a computer of a comrade, php5:
./test.php a=1 b=2
Array
(
)

wazaa
11-09-2005, 01:49 PM
Noone have any idea? I am going to begin to think that I was using a bug very interesting to do scripts...
:_(

tunage
11-09-2005, 02:04 PM
Can you show the full form and how your assigning the variables a=1 b=2 c=3 ?

goldbug
11-09-2005, 04:50 PM
I'm assuming you're talking about a shell script here...

EDIT: NM, register_argv_argc is always enabled when using PHP5 CLI, but there is no $_GET with PHP5 CLI.

Check out the PEAR Console_GetOpt package.

An alternative: switch your $_GET to $argv or $_SERVER['argv'] in your scripts.

thorpe
11-09-2005, 07:00 PM
as far as im aware $_GET and $_POST dont exist in shell scripts. why would they? they refer to the hypertext transfer proticol's get / post request, and a shell script has nothing to do with the hypertext transfer proticol.

wazaa
11-10-2005, 06:30 AM
Well, thorpe, in php4 I can assure you that this worked. In his momenth I tested this, this worked, so I used this, why not If this does what I needed?

Tunage, the thing that I'm runningis:
./test.php a=1 b=2 c=3

glodbug, thx for the info, I am going to test this pear package.