How to store array in Constants?

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Anubis is the god of death in ancient egpypt
Seçkin Üye
Katılım
27 Ocak 2020
Mesajlar
341
Tepki puanı
18
Ödüller
3
6 HİZMET YILI
You can not store array in php constants.
Because php constant can store single string only.
BUT if you serialize an array to string then you can store it constants in constnats.
See Examples:

Kod:
define ("MY_FRUITS", serialize (array ("apple", "cherry", "banana","mango")));
 
Seçkin Üye
Katılım
14 Ocak 2019
Mesajlar
328
Çözümler
1
Tepki puanı
4
Ödüller
5
Yaş
28
7 HİZMET YILI
You can also serialize your array and then put it into the constant
 
Banlı Üye
Katılım
9 May 2019
Mesajlar
604
Tepki puanı
16
Yaş
34
7 HİZMET YILI
it is similar to the example provided by soulmerge, but this way you can get the full array or just a single value in the array. You can store it as a JSON string in a constant. And application point of view, JSON can be useful in other cases.
 
Anyways
Süper Üye
Katılım
16 May 2018
Mesajlar
773
Tepki puanı
197
Ödüller
8
Yaş
27
8 HİZMET YILI
You can store it as a JSON string in a constant. And application point of view
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst