Am 29.06.2017 um 11:08 schrieb Marco Pivetta:
Final is about having immutable data. Immutable doesn't mean that it's a system wide constant, it means that it's referentially pure in its scope.
i refered to "why you would forcefully need it to be a variable still then if you know the value is gonna be constant" and as long constants in PHP are a) very expensive and b) "const" pretends to be compile time which is provable wrong with my sample code are terrible to use
in other languages like Visual Basic constants are fast, in PHP they are slow, both in define and access
On 29 Jun 2017 11:05 AM, "[email protected] <mailto:[email protected]>" <[email protected] <mailto:[email protected]>> wrote:Am 29.06.2017 um 04:50 schrieb Kalle Sommer Nielsen: 2017-06-28 20:46 GMT+02:00 David Rodrigues <[email protected] <mailto:[email protected]>>: 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;-- PHP Internals - PHP Runtime Development Mailing ListTo unsubscribe, visit: http://www.php.net/unsub.php
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
