note 126937 added to language.constants
| From: | insta= at emnatkins-&*iran*& | Date: | Thu, 17 Mar 2022 20:15:14 +0000 |
| Subject: | note 126937 added to language.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217738@lists.php.net to get a copy of this message | ||
for ($i=0;$i<30;$i++){
define("day", $i);
echo $i;
}
========================== or ==========================
define("A",10);
define("B",25);
echo constant("A") + constant("B") ;
========================== or ==========================
class A
{
const foo = 'bar';
}
echo A::foo;
========================== or ==========================
define('ANIMALS', ['dog','cat','bird']);
var_dump(ANIMALS);
========================== or ==========================
if (!defined('SITE_NAME')) {
const SITE_NAME = "SokanAcademy";
}
echo SITE_NAME;
========================== or ==========================
class A
{
const foo = 'bar';
public function getConstant( $const )
{
return constant('self::' . $const);
}
}
$classA = new A();
// Returns bar
echo $classA->getConstant( 'foo' );
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 188.253.75.182)
----
Manual Page -- https://php.net/manual/en/language.constants.php
Edit -- https://main.php.net/note/edit/126937
Del: integrated -- https://main.php.net/note/delete/126937/integrated
Del: useless -- https://main.php.net/note/delete/126937/useless
Del: bad code -- https://main.php.net/note/delete/126937/bad+code
Del: spam -- https://main.php.net/note/delete/126937/spam
Del: non-english -- https://main.php.net/note/delete/126937/non-english
Del: in docs -- https://main.php.net/note/delete/126937/in+docs
Del: other reasons-- https://main.php.net/note/delete/126937
Reject -- https://main.php.net/note/reject/126937
Search -- https://main.php.net/manage/user-notes.php