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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:23:58+00:00 2026-06-08T08:23:58+00:00

class ab{ public static $abc = 34; public static function asd(){ $a = abc;

  • 0
class ab{
    public static $abc = 34;
    public static function asd(){
        $a = "abc";
        echo self::$a;  //output 34;
    }
}
ab::asd();

i want to find a way to point to a class static member .like the example above,how can i make this work?

  • 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-08T08:24:01+00:00Added an answer on June 8, 2026 at 8:24 am

    If you access a static variable, the syntax is the following:

    MyClass::$variable
    

    So what you’re doing lacks the indirection:

    echo self::$$a;  //output 34;
    

    This works with regular variables the same way:

    $variable
    

    and with indirection:

    $name = "variable";
    $$name
    

    An advice for your next question: Try to be more precise in your question. Pay attention to the following:

    • What you have
    • What it should do
    • What actually does
    • Where the error occurs if you know

    This helps to give relevant answers more quickly instead of engaging in a meta-discussion to clarify your question.

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

Sidebar

Related Questions

So if i have something like this: public class TestClass { public static void
public class ABC{ public static void main(string... as) { char i; i = System.console().readLine(Hi
I have something like this : class ParentClass { public static const ON_SOME_EVT:String =
i have classes like this class A : public QDialog { A(QWidget *parent); static
Consider this case: public Class1 { public static final String ONE = ABC; public
I have this class: public static class CsvWriter { private static StreamWriter _writer =
I had a class: public class Constant { public static string ConnString = ConfigurationManager.ConnectionStrings[ConnString].ConnectionString;
i have a class: public class Vars { public static final String NAME =
Consider the following Java class: public class Foo { public static void doStuff() {
Say I have a class: public class R { public static final int _1st

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.