note 57259 added to language.constants
| From: | dqminhatagudotedudotvn at osu1 dot php dot net | Date: | Wed, 28 Sep 2005 16:17:23 +0000 |
| Subject: | note 57259 added to language.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95932@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/language.constants.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57259
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57259&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57259&report=yes
Search -- http://master.php.net/manage/user-notes.php