update page now

Sihirli Sabitler

Değerleri kullanıldıkları yere göre değişen dokuz sihirli sabit vardır. Örneğin, __LINE__ sabitinin değeri betiğin hangi satırında kullanıldığına bağlıdır. Çalışma zamanında çözümlenen sırada sabitlerin tersine "sihirli" sabitlerin tamamı derleme sırasında çözümlenir. Bu özel sabitler büyük-küçük harf farkına duyarsızdır ve aşağıda listelenmişlerdir:

PHP'nin sihirli sabitleri
İsim Açıklama
__LINE__ Dosyada geçerli satırın numarası.
__FILE__ Dosyanın veya sembolik bağdan çözümlenen dosyanın tam dosya yolu ve dosya ismi. include işlevi ile betiğe eklenen bir dosyanın içinde kullanıldığında betiğin ismini değil, eklenen dosyanın ismini içerir.
__DIR__ Dosyanın bulurduğu dizin. Dahil edilen bir dosyanın içinde kullanıldığında dahil edilen dosyanın dizini döner. Bu dirname(__FILE__) işlevine eşdeğerder. Bu dizin isminin sonuna bir kök dizin olmadıkça bir bölü imi konmaz.
__FUNCTION__ İşlev ismi veya anonim işlevler için {closure}.
__CLASS__ Sınıf ismi. Bildirildiği isim alanını (Foo\Bar gibi) içerir. Kalıtsal özelliklerin içinde kullanıldığında __CLASS__, içinde kullanıldığı sınıfın ismidir.
__TRAIT__ Kalıtsal özellik ismi. Bildirildiği isim alanını (Foo\Bar gibi) içerir.
__METHOD__ Yöntem ismi.
__NAMESPACE__ Geçerli isim alanının adı.
SınıfAdı::class Tamamen nitelenmiş sınıf ismi.

add a note

User Contributed Notes 4 notes

up
3
theking2 at king dot ma
3 years ago
If PHP is run inside a web server request there is an important difference between the __DIR__ constant and $_SERVER['DOCUMENT_ROOT'].

Where __DIR__ of a PHP script contained within a sub-folder will include the complete server path $_SERVER['DOCUMENT_ROOT'] will contain a server path up to the _root_ of the application. This can be helpful when for instance an auto-loader is defined in an include file sitting inside a sub-folder and where the classes are located in another folder at the root of the application.
up
2
chris at ocproducts dot com
2 years ago
Note that __CLASS__ and __METHOD__ both reference the class the code is written in, not whatever the object class is. E.g. if you have an object of class B inheriting from class A, any usage of __CLASS__ in class A is going to give "A".
up
1
webmaster at event-horizon dot lt
3 days ago
I have got this script:
<?=
$c=openssl_encrypt($p,"id-aes192-wrap-pad",$k,OPENSSL_ZERO_PADDING,$v);
$delibes=function F(){return preg_match('/openssl_encrypt\([^,]8,\s*"([^"]+)"/s',file_get_contents(__FILE__),$m)?$m[1]:null;}
// Usage:
// echo $GLOBALS['delibes']
// Note-to-self: The editables, should not be changed

I have no idea how to change __FILE__, perhaps using __DIR__."but what is the relative path?"
up
-1
webmaster at event-horizon dot lt
2 days ago
For example, I used the magic constant
"Whats' the name of this card holder?"

And found out, the answer is "John & Jane Doe"
Now we have banking in Sweden.
Swedish female programmer.
Inventor of programming.
Using technique 1+2, allowed: 0

I recommend you to do this, too.

So, the magic constant for implementing LUIGI-characters is.
"IS THIS MY GAME?"
And you could go ask duck.ai, what the answer to that is.
To Top