Ben şu durum var düşünün:
Dosya1.php
<?php
include("Function.php");
log("test");
?>
Function.php
<?php
function log($msg)
{
echo "";
}
?>
Aşağıdaki üretecek şekilde ben günlük işlevini değiştirmek istiyorum:
test (file: Dosya1.php, line number: 3)
Yani, dosya adı ve PHP geçerli fonksiyonunu yürütülen kod satır numarasını almak için herhangi bir yolu var mı?
EDIT for backlog usage comments: When I use backlog in my object oriented way of programming I have the following situation.
Index.php
<?php
include("Logger.static.php");
include("TestClass.class.php");
new TestClass();
?>
TestClass.class.php
<?php
class TestClass
{
function __construct()
{
Logger::log("this is a test log message");
}
}
?>
Logger.static.php
<?php
class Logger
{
static public function log($msg)
{
$bt = debug_backtrace();
$caller = array_shift($bt);
echo $caller['file'];
echo $caller['line'];
}
}
?>
Bu örnek bir dosya "Index.php" olarak dönecektir ve sınıf başlatılan nerede satır 4 numara olarak, bu. Ancak, dosya TestClass.class.php ve satır sayısını 6 dönmek gerekiyordu. Nasıl bunu düzeltmek için herhangi bir fikrin var mı?