<?php
namespace My\App {
class Api {
public static fetch() {
print __FUNCTION__ . "\n"; // 輸出 fetch
print __METHOD__ . "\n"; // 輸出 My\App\Api::fetch
}
}
Api::fetch();
}
namespace {
My\App\Api::fetch();
}
?>
__METHOD__ 輸出完整的 method 名稱(包含命名空間);__FUNCTION__ 在 method 中使用時,只輸出 method 名稱。