note 59106 added to function.constant
| From: | timneill at hotmail dot com | Date: | Sat, 26 Nov 2005 08:39:34 +0000 |
| Subject: | note 59106 added to function.constant | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99131@lists.php.net to get a copy of this message | ||
Please note when using this function from within a class to retrieve a php5 class constant, ensure
you include the 'self::'.
class Validate
{
const TEXT_MAX = 65536;
//-- this will work
public static function textWORKS($_value, $_type = 'TEXT')
{
$_max = constant('self::' . $_type . '_MAX');
return (strlen($_value) <= $_max ? true : false);
}
//-- this will fail
public static function textFAILS($_value, $_type = 'TEXT')
{
//-- Debug Warning: constant(): Couldn't find constant TEXT_MAX
$_max = constant($_type . '_MAX');
return (strlen($_value) <= $_max ? true : false);
}
}
----
Manual Page -- http://www.php.net/manual/en/function.constant.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59106
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59106&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59106&report=yes
Search -- http://master.php.net/manage/user-notes.php