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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:24:46+00:00 2026-06-02T22:24:46+00:00

I am pulling my hair out on this one. Pretty new at PHP but

  • 0

I am pulling my hair out on this one. Pretty new at PHP but this is so basic I just can’t figure out where the problem is. Using the code snippet below as an example:

class LG_Activity_Processor {
// Activity Types
const STATUS_DRAFT = 'draft';
const STATUS_PUBLISH = 'publish';
...
private $STATUS_FUTURE = 'future';
define ("STATUS_PRIVATE" , 'private');

I had originally intended to just use the “const” construct as the variables are fully defined prior to run time and I just think the syntax is prettier than that ugly “define”. The problem is while the definition of the const gives no errors, whenever I refer to the constant later in the class I get the following error message:

PHP Notice: Use of undefined constant STATUS_PUBLISH – assumed ‘STATUS_PUBLISH’

Huh? Just to be clear, here’s the syntax I used to reference the “const”:

$core_fields ['post_status'] = STATUS_PUBLISH;

I even tried:

$core_fields ['post_status'] = $this->STATUS_PUBLISH;

No love. I then entered a state of despair and eventually tried “define”. Same calling syntax but I changed the definition syntax to that as illustrated above for “STATUS_PRIVATE”. This made things far worth as I now had a fatal error on the define line that looked like this:

PHP Parse error:  syntax error, unexpected T_STRING, expecting T_FUNCTION

I gave up. I finally just defined the variable as a private variable (as in the example of STATUS_FUTURE) and then referred to it as:

$core_fields ['post_status'] = $this->STATUS_PUBLISH;

That works just like you’d expect it to but I can’t help but feeling I’ve been cheated out of doing it the right way. Any ideas on how to make my code whole again?

  • 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-02T22:24:54+00:00Added an answer on June 2, 2026 at 10:24 pm

    You should do LG_Activity_Processor::STATUS_DRAFT when accessing it.

    Take a look at the PHP manual, it gives you clear examples.

    http://php.net/manual/en/language.oop5.constants.php

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

Sidebar

Related Questions

I've been pulling my hair out over this one and I just can't get
I am pulling my hair out on this one... I am using the ASIHTTPRequest
I'm pulling my hair out here, because I just can't seem to get this
I have been pulling my hair trying to figure this out but nothing is
I am pulling the hair out of my head trying to figure this one
I'm pulling my hair out on this one. I'm using the FlexSlider on a
I am pulling me hair out about this one. http://www.nettunes.co.za/build/contact.php I have an image
Pulling my hair out over this one. I have one wordpress install at /2009
I'm pulling my hair out on this. I do some manual deserialization using XmlReader
I'm really pulling my hair out on this one, it seems that I'm having

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.