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 4244548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:43:21+00:00 2026-05-21T03:43:21+00:00

define(‘VAR_1’, ‘Some info 01’); define(‘VAR_2’, ‘Some info 02’); define(‘VAR_3’, ‘Some info 03’); define(‘VAR_4’, ‘Some

  • 0
define('VAR_1', 'Some info 01');
define('VAR_2', 'Some info 02');
define('VAR_3', 'Some info 03');
define('VAR_4', 'Some info 04');
define('VAR_5', 'Some info 05');
define('VAR_6', 'Some info 06');
define('VAR_7', 'Some info 07');
  • 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-05-21T03:43:21+00:00Added an answer on May 21, 2026 at 3:43 am

    I usually namespace my constants, if I’ve got many of them, in a class like so:

    class Foo {
        const Bar = 1;
        const Baz = 2;
    
        public static $array = array(1,2,3);
    }
    
    echo Foo::Bar; # Accessing the constants
    print_r(Foo:$array);
    

    Putting an Array in a constant is not possible for class constants, and I don’t think it is a good practice putting them in global constants either, if it is even possible (not sure). Maybe you should tell us what you are trying to accomplish, maybe there is a better way to do it.

    Oh, and please don’t do something like this:

    for($x=0; x<10; $x++) {
        define('VAR_' . $x, 'Information #' . $x);
    }
    

    Which has been suggested here, but IMHO this is absolutely not how constant are supposed to be used.

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

Sidebar

Related Questions

#define INIT_MACRO create(); some(); enviroment(); ... void function(){ INIT_MACRO extra_indented(); normal_indented(); } how do
#define boo(fmt, ...) SomethingToDo(fmt, __VA_ARGS__) void foo(PCSTR fmt, ...) { // some other codes
Define a function replicate which given a list of numbers returns a list with
#define __T(x) L ## x Found in code from one of the MFC source
#define OUTGOING_MASK 0x0c #define OUTGOING_DISABLED 0x04 #define OUTGOING_ENABLED 0x08 #define OUTGOING_AUTO 0x00 #define REFER_SUPPORTED
#define cimg_use_jpeg 2 #ifndef cimg_use_jpeg //code goes here #endif I really don't understand...
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) \ static CEntityFactory<DLLClassName> mapClassName( #mapClassName ); This is a macro from the
(define pick (lambda (num lat) (cond ((null? lat) (quote())) ((= (sub1 num) 0) (car
#define NAME(x) TEXT(x) #define TEXT(quote) __TEXT(quote) // r_winnt #define __TEXT(quote) quote // r_winnt The
I define each actions in my controller this way (in routes.rb ): resources :home

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.