Nura111
asked on
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!
const KEYWORDS_THRESHOLD = 0.95;
How to I access it with function within the class?
Thank you!
ASKER
but withing the clas its the same thing? they dont shoe it in the exmple I cant use this->
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
from outside I use name::foo()
but from withing the class same wuestion can I use this->foo as regular function?
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;
http://php.net/manual/en/language.oop5.constants.php