本文整理汇总了PHP中MyClass::WhoAmI方法的典型用法代码示例。如果您正苦于以下问题:PHP MyClass::WhoAmI方法的具体用法?PHP MyClass::WhoAmI怎么用?PHP MyClass::WhoAmI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyClass
的用法示例。
在下文中一共展示了MyClass::WhoAmI方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WhoAmI
return __FUNCTION__;
}
class MyClass
{
static function WhoAmI()
{
return __METHOD__;
}
}
echo MYCONST . "<br/>";
// App\Lib1\MYCONST
var_dump(MYCONST) . "<br/>";
// string(16) "App\Lib1\MYCONST"
echo MyFunction() . "<br/>";
// App\Lib1\MyFunction
var_dump(MyFunction()) . "<br/>";
// string(19) "App\Lib1\MyFunction"
echo "<br/>" . MyClass::WhoAmI() . "<br/>";
// App\Lib1\MyClass::WhoAmI
var_dump(MyClass::WhoAmI()) . "<br/>";
// string(24) "App\Lib1\MyClass::WhoAmI"
?>
<?php
// myapp.php
header('Content-type: text/plain');
require_once 'lib1.php';
// calling lib1.php
echo \App\Lib1\MYCONST . "\n";
echo \App\Lib1\MyFunction() . "\n";
echo \App\Lib1\MyClass::WhoAmI() . "\n";
开发者ID:KB-WEB-DEVELOPMENT,项目名称:Kami_Barut_PHP_projects,代码行数:31,代码来源:accessing+namespace+content+in++a+file.php
示例2: header
?>
<?php
namespace App\Lib1;
require_once 'lib1.php';
// const, functions and classes here will be called
require_once 'lib2.php';
// const, functions and classes here will not be called
header('Content-type: text/plain');
echo MYCONST . "\n";
// App\Lib1\MYCONST
echo MyFunction() . "\n";
// App\Lib1\MyFunction
echo MyClass::WhoAmI() . "\n";
// App\Lib1\MyClass::WhoAmI
?>
<?php
use App\Lib2;
require_once 'lib1.php';
require_once 'lib2.php';
header('Content-type: text/plain');
echo Lib2\MYCONST . "\n";
// App\Lib1\MYCONST ATTENTION !
echo Lib2\MyFunction() . "\n";
// App\Lib2\MyFunction
echo Lib2\MyClass::WhoAmI() . "\n";
// App\Lib2\MyClass::WhoAmI
?>
开发者ID:KB-WEB-DEVELOPMENT,项目名称:Kami_Barut_PHP_projects,代码行数:31,代码来源:Accessing+data+from+various+namespaces.php
示例3: WhoAmI
class MyClass
{
public function WhoAmI()
{
return __METHOD__;
}
}
$c = __NAMESPACE__ . '\\MyClass';
$m = new $c();
echo $m->WhoAmI() . '<br/>';
// output: App\Lib1\MyClass::WhoAmI
var_dump($m->WhoAmI());
// output: string(24) "App\Lib1\MyClass::WhoAmI"
?>
<?php
// namespace keyword
namespace App\Lib1;
class MyClass
{
public function WhoAmI()
{
return __METHOD__;
}
}
$m = new namespace\MyClass();
echo $m->WhoAmI() . '<br/>';
// output: App\Lib1\MyClass::WhoAmI
var_dump($m->WhoAmI());
// output: string(24) "App\Lib1\MyClass::WhoAmI"
开发者ID:KB-WEB-DEVELOPMENT,项目名称:Kami_Barut_PHP_projects,代码行数:31,代码来源:namespace+constants+and+keywords.php