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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:10:02+00:00 2026-06-10T16:10:02+00:00

Is it better to check whether a constant exists before setting it? Or is

  • 0

Is it better to check whether a constant exists before setting it? Or is it ok to just set it directly? I am creating a WordPress plugin and setting a few constants, I’ve seen some plugins that set them directly and others check via if !(defined)

  • 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-10T16:10:03+00:00Added an answer on June 10, 2026 at 4:10 pm

    It depends. If you may reasonably expect the constant to already exist, then you should check. If you are sure the constant must not exist at this point because you need to define it, you should not check and let PHP fail hard if your expectation is not met. Errors help to pinpoint problems.

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

Sidebar

Related Questions

In my SQL query I just need to check whether data exists for a
So I'm need to check whether a file exists before showing specific data to
Is there a better way to check whether a file exists (it is on
Any suggestions on whether fewer check constraints are better, or more? How should they
Is it better to check for a defined constant, check the url, or any
Possible Duplicate: Check whether a Directory Exists in PHP I am trying scandir() to
I wrote this sample code to check whether integer or string index is better
I'm trying to check whether a functor is compatible with a given set of
Before saving the user entered data I want to check whether the entered data
I want to check whether the title of a UINavigationItem is truncated. I set

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.