note 57259 deleted from language.constants by nlopess

From: Date: Thu, 29 Sep 2005 08:31:11 +0000
Subject: note 57259 deleted from language.constants by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-95959@lists.php.net to get a copy of this message
Note Submitter: dqminh at agu dot edu dot vn ---- I m writting a logging system using PHP/MySQL. At this moment, there are four different activities need to be logged: access, error, alert, and logonoff. I chose to store the string in database, so this is my code: <?php define("LOG_ONOFF", "ONOFF"); define("LOG_ALERT", "ALERT"); define("LOG_ACCESS", "ACCESS"); define("LOG_ERROR", "ERROR"); $type = strtoupper($_POST["type"]); $logtypes = array(LOG_ONOFF, LOG_ALERT, LOG_ERROR, LOG_ACCESS); //create the query string here //......bluh bluh bluh if (in_array($type, $logtypes)) $_strsql .= " AND logtype = '$type'"; //.....more code ?> You know what happen? when I choose type="ALERT" the output always shows up with all types of log record. But not happen if I choose "ONOFF" or "ACCESS" or "ERROR". To debug, I print out the array: <?php print_r($logtypes) ?> This is what I get: <? Array ( [0] => ONOFF [1] => 1 [2] => ERROR [3] => ACCESS ) ?> Why? I think the "ALERT" constant was treated specially in PHP. If I declare $logtypes=array("ONOFF", "ALERT", "ERROR", "ACCESS") I got no problem. I wonder if any other words that are treated like ALERT in PHP constant? Minh Duong

« previous php.notes (#95959) next »