Is "Function Constants" the Correct Term?
| From: | gohaku | Date: | Sat, 17 Jul 2004 21:42:12 +0000 |
| Subject: | Is "Function Constants" the Correct Term? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-190861@lists.php.net to get a copy of this message | ||
Hi everyone,
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));
DBLOGIN;
$set = mysql_query("Select user FROM user limit 1,1");
$results = mysql_fetch_array($set);
echo "Results: ",$results["user"];
define(DBLOGIN,dblogin("user","incorrect_pass",DB));
DBLOGIN;
//Should print error
$set = mysql_query("Select user FROM user limit 1,1");
$results = mysql_fetch_array($set);
echo "Results: ",$results["user"];
function dblogin($login,$pass,$db)
{
$mysql = mysql_connect("localhost",$login,$pass);
mysql_select_db($db,$mysql);
}
?>
</pre>
I would like to know what the right term for this kind of constant since a search for "function constants" php
did not return any relevant results.
I would also like to know why I was able to redefine DBLOGIN, I always thought redefining constants could
not be done.
Thanks in advance.
-gohaku