How to access const in a php class?

how to access const in a php class?

const  KEYWORDS_THRESHOLD = 0.95;

How to I access it with function within the class?

Thank you!
Nura111Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amiguraCommented:
echo class_name::KEYWORDS_THRESHOLD;

http://php.net/manual/en/language.oop5.constants.php
0
Nura111Author Commented:
but withing the clas its the same thing? they dont shoe it in the exmple I cant use this->
0
DerokorianCommented:
class foo {
   const BAR = 'Hello World!';

   public function __construct() {
      echo self::BAR;
   }
}

$foo = new foo;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nura111Author Commented:
ok thanks and if a function is public static function foo()

from outside I use name::foo()

but from withing the class same wuestion can I use this->foo as regular function?
0
DerokorianCommented:
Yes:

class foo {
   const BAR = "Hello World!";

   public static function boldBar() {
      echo '<strong>'.self::BAR.'</strong>';
   }
   public function __construct() {
      $this->boldBar();
   }
}

foo::boldBar();
$foo = new foo;

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.