Page 1 of 1

$_GET()

PostPosted: 08. March 2023 20:06
by gmeyers1
I am new to XAMPP. I just installed version 8.2.0 on Windows 11. I have existing PHP code (older version) that uses the $_GET() method to get command line args. But is doesn't work with XAMPP. Is this a bug or has this method be dropped?

Re: $_GET()

PostPosted: 09. March 2023 03:05
by Altrea
Hi gmeyers1,

gmeyers1 wrote:I have existing PHP code (older version) that uses the $_GET() method to get command line args.

What means "older version"?
What means command line args?
Can you show us the code?

gmeyers1 wrote:But is doesn't work with XAMPP.

What does that mean? Describe as detailed as possible.
What did you expect to happen and what happens instead?
Are there any other information like error messages on the screen or the log files?

[quote="gmeyers1]Is this a bug or has this method be dropped?[/quote]
No. $_GET is one of the most important superglobals in PHP.
If you are not sure whether a feature or function is implemented in a PHP major version, you can always look this up in the manual.
For example for the $_GET superglobal, you see it is implemented in "PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8"

Very likely it is a problem with your code, but without knowing your code it is nearly impossible to provide sufficient help.

Re: $_GET()

PostPosted: 09. March 2023 17:12
by gmeyers1
Here's a snippet of the code that fails with "$func is undefined". The code is invoked from another section by: titles.php?func=1

========================================
<?php
require_once("utility.php");

$func = $_GET[func];
database_connect();

if ($func == 1)
{
===========================================

utility.php has many methods including database_connect(). However the code fails before executing that command.

My code was written with version 5.4.36.

Re: $_GET()

PostPosted: 12. March 2023 16:43
by Nobbie
gmeyers1 wrote:$func = $_GET[func];


This is already an error, the arguments of $_GET must be defined. func is an undefined constant (and you should get a message "undefined constant"). In earlier PHP versions it was accepted and treated as a string, probably in PHP 8.2 this is not accepted anymore. The correct syntax would be:

Code: Select all
$func = $_GET["func"];



So your error might be a follow up error, but we also have to know, what you precisely mean by "is invoked". Can we see the other section also?