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 — Önbellekten bir sabit kümesini yükler
Açıklama
bool apc_load_constants
( string
$anahtar
[, bool $buyukluk_duyarli = true
] )Önbellekten bir dizi sabiti yükler.
Değiştirgeler
-
anahtar -
Sabitleri yığın halinde apc_define_constants() ile önbelleğe saklarken verilmiş isim.
-
buyukluk_duyarli -
İşlevin öntanımlı davranışı harf büyüklüğüne duyarlıdır, yani SABIT ile Sabit farklı değerlerdir. Eğer bu değiştirge
FALSEolarak ayarlanırsa sabitler harf büyüklüğüne duyarsız sembollerle tanımlanacaktır.
Dönen Değerler
Başarı durumunda TRUE, başarısızlık durumunda FALSE döner.
Örnekler
Örnek 1 - apc_load_constants() örneği
<?php
$sabitler = array(
'BIR' => 1,
'IKI' => 2,
'UC' => 3,
);
apc_define_constants('sayilar', $sabitler);
apc_load_constants('sayilar');
echo BIR, IKI, UC;
?>
Yukarıdaki örneğin çıktısı:
123
Ayrıca Bakınız
- apc_define_constants() - Yeniden çağırmak ve yığın tanımlama için bir grup sabit tanımlar
- define() - Bir isimli sabit tanımlar
- constant() - Bir sabitin değerini döndürür
- veya PHP Sabitleri Belgesi
webmaster at thedigitalorchard dot ca
25-Apr-2010 05:41
