Bu komut PHP tarafından çağrılan bir sınıftan bir yerini kontrol edin: s

0 Cevap

Ben bir sınıf (örneğin Database) varsa ben bu sınıf örneğini çalıştı script yerini kontrol edebilirsiniz.

Örnek:

Ben şöyle bir örnek dir yapıya sahiptir:

lib
  Database.class.php
app
  action.class.php

ve action.class.php içinde:

$db = new Database;

ve Database.class.php içinde

function __construct(){
$name = //some code to find out that app/action.class.php just tried to instantiate me
$name = explode('/',$name);
if($name[0] = 'app') //allow script to use the class
else $this->__destruct; //dont allow other scripts not in app dir for example
}

Ben bu mümkün olup olmadığını bilmiyorum

Regards Luke

GÜNCELLEME: It seems like this is possible but not good practice (from answers below) thank you for your time, I wont be implimenting this mainly due to @Gordons argument.

0 Cevap