There doesn't seem to be a way to store constants that have already been defined. This function, apc_define_constants(), does both things: (1) defines a constant, and (2) stores the constant in the cache. This is unfortunate, since it introduces the requirement to handle constant definitions differently when APC is not available.
(If this function had a "$do_not_define" parameter, or the like, that would give it more flexibility. I suppose filing a bug report would be a step in the right direction to getting this idea considered.)
apc_load_constants
(PECL apc >= 3.0.0)
apc_load_constants — بارگذاری یک مجموعه ثابت از کاشه
Description
bool apc_load_constants
( string $key
[, bool $case_sensitive = true
] )
بارگذاری یک مجموعه ثابت از کاشه.
Parameters
- key
-
نام مجموعه ثابت که باید بازیابی شود (به همراه apc_define_constants() ذخیره شده است).
- case_sensitive
-
رفتار پیشفرض ثابتها به صورت حساس به بزرگی و کوچکی باید تعیین شود، به عنوان مثال CONSTANT و Constant نشاندهنده دو مقدار متفاوت هستند. اگر این پارامتر برابر با FALSE ارزیابی گردد ثابتها به صورت نشانهای غیرحساس به بزرگی و کوچکی اعلام خواهند شد.
Return Values
Returns TRUE on success or FALSE on failure.
Examples
Example #1 مثال apc_load_constants()
<?php
$constants = array(
'ONE' => 1,
'TWO' => 2,
'THREE' => 3,
);
apc_define_constants('numbers', $constants);
apc_load_constants('numbers');
echo ONE, TWO, THREE;
?>
The above example will output:
123
See Also
- apc_define_constants() - مجموعهای از ثوابت برای بازیابی و تعریف گسترده فراهم میکند.
- define() - Defines a named constant
- constant() - Returns the value of a constant
- Or مرجع ثوابت PHP
webmaster at thedigitalorchard dot ca ¶
3 years ago
