note 59106 deleted from function.constant by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 14:54:50 +0000 |
| Subject: | note 59106 deleted from function.constant by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197229@lists.php.net to get a copy of this message | ||
Note Submitter: timneill at hotmail dot com
----
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);
}
}