Re: Is "Function Constants" the Correct Term?

From: Date: Sun, 18 Jul 2004 14:56:53 +0000
Subject: Re: Is "Function Constants" the Correct Term?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190912@lists.php.net to get a copy of this message
I have been experimenting with defining functions as constants. Below is what I am using to test "Function Constants": <pre> <? define(LOGIN,"user"); define(PASS,"pass"); define(DB,"mysql"); define(DBLOGIN,dblogin(LOGIN,PASS,DB));
This is simply not allowed. see: http://php.net/define Can you elaborate on what is not allowed? Are you saying defining function constants are not allowed or are you saying redefining constants are not allowed?
I believe the answer is that both concepts are not allowed. Constants, by their very definition, cannot be redefined (except for magic constants, which is a different thing). Also, constants must be set as scalar values. PHP doesn't support function-like macros as you might have seen in the C preprocessor. This is all in the PHP manual, under define() and constants. Larry

« previous php.general (#190912) next »