ReflectionClass::getDocComment()函數是PHP中的內置函數,用於返回特定的doc注釋(如果存在),否則返回false。
用法:
string ReflectionClass::getDocComment( void )
參數:該函數不接受任何參數。
返回值:此函數返回指定的文檔注釋(如果存在),否則返回false。
以下示例程序旨在說明PHP中的ReflectionClass::getDocComment()函數:
示例1:
<?php
// Below is the doc comments
/**
* Below program is
* about getting the
* doc comments.
*/
// Defining a class named as Departments
class Departments {}
// Using ReflectionClass over the class Departments
$ReflectionClass = new ReflectionClass('Departments');
// Calling getDocComment() functions
$A = $ReflectionClass->getDocComment();
// Getting specified doc comments
var_dump($A);
?>
輸出:
string(66) "/** * Below program is * about getting the * doc comments. */"
示例2:
<?php
// Defining a class named as Departments
class Departments {}
// Using ReflectionClass over the class Departments
$ReflectionClass = new ReflectionClass('Departments');
// Calling getDocComment() functions
$A = $ReflectionClass->getDocComment();
// Getting specified doc comments
var_dump($A);
?>
輸出:
bool(false)
參考: https://www.php.net/manual/en/reflectionclass.getdoccomment.php
相關用法
- PHP ReflectionProperty getDocComment()用法及代碼示例
- PHP ReflectionClass isInstantiable()用法及代碼示例
- PHP ReflectionClass isInterface()用法及代碼示例
- PHP ReflectionClass getFileName()用法及代碼示例
- PHP ReflectionClass getTraitAliases()用法及代碼示例
- PHP ReflectionClass getStaticPropertyValue()用法及代碼示例
- PHP ReflectionClass isInstance()用法及代碼示例
- PHP ReflectionClass getInterfaces()用法及代碼示例
- PHP ReflectionClass getStaticProperties()用法及代碼示例
- PHP ReflectionClass export()用法及代碼示例
- PHP ReflectionClass inNamespace()用法及代碼示例
- PHP ReflectionClass hasMethod()用法及代碼示例
- PHP ReflectionClass getExtension()用法及代碼示例
- PHP ReflectionClass getExtensionName()用法及代碼示例
- PHP ReflectionClass getConstant()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 PHP | ReflectionClass getDocComment() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。