當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


PHP ReflectionClass getDocComment()用法及代碼示例


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



相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 PHP | ReflectionClass getDocComment() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。