Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:33:02+00:00 2026-06-15T06:33:02+00:00

I knocked to a phenomenon in an existing php source, with field access without

  • 0

I knocked to a phenomenon in an existing php source,
with field access without apostrophe like this: $_GET[test].

I got unsure, also don’t know, that this is a possible way,
so I wrote a short example for testing:

echo "Array Test, fields without apostrophe, like \$_GET[fieldname]<BR><BR>";
$a = array();
$a['test'] = "ArrayValue";
echo "case 1 -> \$a['test']: " . $a['test'] . "<BR>";
echo "case 2 -> \$a[\"test\"]: " . $a["test"] . "<BR>";
echo "case 3 -> \$a[test]: " . $a[test] . "<BR>";

And it works, every result got the value (ArrayValue).

I prefer the access method like case 2.

Is case 3 a normal, allowed coding style in php?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:33:03+00:00Added an answer on June 15, 2026 at 6:33 am

    What happens here, is that PHP sees a constant called test. If the constant is defined, the value is returned, it isn’t defined, PHP falls back to the string "test". For example:

    $array = array("A" => "Foo", "B" => "Bar", "C" => "Baz")
    define("B", "C");
    
    echo $array[A];   // The constant "A" is undefined, 
                      // so PHP falls back to the string "A", 
                      // which has the value "Foo".
    echo $array["B"]; // The result is "Bar".
    echo $array[B];   // The value of constant "B" is the string "C".
                      // The result is "Baz".
    

    It’s for backwards compatibility and you should never use it. If you’ll turn on notices, you’ll see that PHP complains about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this isn't knocked for being too general, but... I recently had occasion
So I knocked up some test code to see how the multiprocessing module would
I just got knocked down after our server has been updated from Debian 4
This seems to be very basic question but I am knocked out. How to
Hi i am struggling with the following i have knocked up a little sample
I have some 1and1.co.uk webspace and a handful of domains. This is grand and
I am making a movement engine for my top-down 2D game, but I got
I have this XML: <rootCategories> <category id=1> <category id=2> <category id=3> <category id=4 />
I'm working on a game and I'd like to give a non-developer friend a
I had a problem this week (which thankfully I've solved in a much better

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.