Re: Final variables

From: Date: Thu, 29 Jun 2017 09:04:48 +0000
Subject: Re: Final variables
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-99672@lists.php.net to get a copy of this message
Am 29.06.2017 um 04:50 schrieb Kalle Sommer Nielsen:
2017-06-28 20:46 GMT+02:00 David Rodrigues <david.proweb@gmail.com>:
The "final" keyworks make a "local scope" variable value "blocked to rewrite" after instantiate it. Okay, it sounds like a "const", and it is, but "not as we known it".
I get that, but I still don't understand why you would forcefully need it to be a variable still then if you know the value is gonna be constant, of course besides global visibility or in iterations
because constants are expensive in PHP when "define()" is a function call and "const" is very limited for no good reason "no good reason" because if it really would be compile time the following won't work and so why can't you use 'const' within a if-statement when you in fact can CONCAT two with define() set constant which are part of a if-statement themself ____________________________________________________ if(PHP_SAPI !== 'cli') { define('MY_PHP_SELF', $_SERVER['SCRIPT_NAME']); define('rh_serverurl', PROTOCOL_PREFIX . MY_SERVER_NAME . $rh_port); } else { define('MY_PHP_SELF', '/' . basename($_SERVER['SCRIPT_NAME'])); define('rh_serverurl', 'http://localhost'); } const rh_phpself = rh_serverurl . MY_PHP_SELF;

« previous php.internals (#99672) next »