利用phpdoc常用标签生成代码说明文档
说明如何使用phpdoc常用标签生成代码说明文档
<?php /** * 记录用于进行BI数据统计的日志类 * @author chenjianbin * @version 1.0 */ class Logger { // 定义操作类型常量 /** * 首次关注 */ const OPT_FIRST_FOCUS = 1; /** * 取消关注 */ const OPT_CANCEL_FOCUS = 2; /** *首次绑定手机 */ const OPT_FIRST_BIND = 3; /** * 取消绑定手机 */ const OPT_CANCEL_BIND = 4; /** * 发送消息 */ const OPT_SEND_MSG = 5; /** * 重新关注 */ const OPT_REPEAT_FOCUS = 6; /** *重新绑定手机 */ const OPT_REPEAT_BIND = 7; // 定义交互类型常量 /** * 发送文本 */ const INTACT_TEXT_MSG = 1; /** * 点击菜单 */ const INTACT_CLICK_MENU = 2; /** * 发送图片 */ const INTACT_PIC_MSG = 3; /** * 发送视频 */ const INTACT_VIDEO_MSG = 4; /** * 发送语音 */ const INTACT_AUDIO_MSG = 5; /** * 发送关键词 */ const INTACT_KEYWORD = 6; // 定义活动类型常量 /** * 抽奖 */ const CAMP_LOTTERY = 1; /** * 调研 */ const CAMP_SURVEY = 2; /** * 晒图 */ const CAMP_SHOWPIC = 3; /** * 红包 */ const CAMP_RED_PACK = 4; /** * 转发红包 */ const CAMP_TRANS_RED_PACK = 5; /** * 刮刮卡 */ const CAMP_SCRATCH_CARD = 6; /** *拆礼盒 */ const CAMP_OPEN_GIFT = 7; /** * 预约 */ const CAMP_APPOINTMENT = 8; /** * 秒杀 */ const CAMP_SECKILL = 9; /** * 团购 */ const CAMP_GROUPON = 10; /** * 组团团购 */ const CAMP_GROUP_BUY = 11; /** * 征集 */ const CAMP_COLLECT = 12; /** * 兑奖模板 */ const CAMP_EXPIRY = 13; /** * 日志路径 * @access private * @var string */ private $_log_path; /** * 系统分支 * @access private * @var string */ private $_branch; /** * 商户id * @access private * @var int */ private $_merchant_id; /** * 商户代码 * @access private * @var string */ private $_merchant_code; /** * 用户id * @access private * @var int */ private $_userid; /** * 用户openid * @access private * @var string */ private $_openid; /** * 用户电话号码 * @access private * @var string */ private $_phone; function __construct() {} /** * 设置日志路径 * @access public * @param string $log_path 日志路径 */ public function set_log_path($log_path) { $this->_log_path = $log_path; } /** * 基本参数设置 * @access public * @param string $branch 分支 * @param int $merchant_id 商户id * @param string $merchant_code 商户代码 * @param int $userid 用户id * @param string $openid 用户openid * @param string $phone 手机号码 */ public function set_base_params($branch, $merchant_id, $merchant_code, $userid, $openid, $phone) { $this->_branch = $branch; $this->_merchant_id = $merchant_id; $this->_merchant_code = $merchant_code; $this->_userid = $userid; $this->_openid = $openid; $this->_phone = $phone; } /** * 用户操作日志 * @access public * @param string $opt_code 操作代码 * @param string $act_code 交互代码 */ public function operate($opt_code, $act_code) { $ctime = date('YmdHis'); $log_arr = array( $this->_branch, $this->_merchant_id, $this->_merchant_code, $this->_userid, $this->_openid, $this->_phone, $opt_code, $ctime, $act_code ); $line = implode('|', $log_arr); $this->_write_log('operate', $line, $date); } /** * 用户访问日志 * @access public * @param string $user_type 用户类型 是否粉丝用户 0/1 * @param int $visit_src 访问来源 1.内部访问;2.外部访问 * @param string $page_title 页面标题 * @param string $visit_url 访问url */ public function visit($user_type, $visit_src, $page_title, $visit_url) { $ctime = date('YmdHis'); $log_arr = array( $this->_branch, $this->_merchant_id, $this->_merchant_code, $this->_userid, $this->_openid, $phone->_phone, $user_type, $visit_src, $page_title, $visit_url, $ctime ); $line = implode('|', $log_arr); $this->_write_log('visit', $line, $date); } /** * 活动记录日志 * @access public * @param string $user_type 用户类型 * @param int $visit_src 访问来源 1.内部访问;2.外部访问 * @param string $activity_id 活动id * @param string $activity_url 活动url * @param string $activity_title 活动标题 * @param string $activity_type 活动类型 * @param string $activity_status 活动状态 * @param string $send_userid 发起分享的用户id * @param string $rece_userid 接受分享的用户id * @param string $share_num 分享生成的唯一序列号 */ public function activity ( $user_type, $visit_src, $activity_id, $activity_url, $activity_title, $activity_type, $activity_status, $send_userid, $rece_userid, $share_num) { $ctime = date('YmdHis'); $log_arr = array( $this->_branch, $this->_merchant_id, $this->_merchant_code, $this->_userid, $user_type, $this->_openid, $this->_phone, $visit_src, $activity_id, $activity_url, $activity_title, $activity_type, $activity_status, $send_userid, $rece_userid, $share_num, $ctime ); $line = implode('|', $log_arr); $this->_write_log('activity', $line, $date); } /** * 菜单统计日志 * @access public * @param string $menu_key 菜单key * @param string $menu_name 菜单名称 * @param string $parent_name 父菜单名称 */ public function menu($menu_key, $menu_name, $parent_name) { $ctime = date('YmdHis'); $log_arr = array( $this->_branch, $this->_merchant_id, $this->_merchant_code, $this->_userid, $this->_openid, $this->_phone, $menu_key, $menu_name, $parent_name, $ctime ); $line = implode('|', $log_arr); $this->_write_log('menu', $line, $date); } /** * 关键词统计日志 * @access public * @param string $keyword 关键词 */ public function keyword($keyword) { $ctime = date('YmdHis'); $log_arr = array( $this->_branch, $this->_merchant_id, $this->_merchant_code, $this->_userid, $this->_openid, $this->_phone, $keyword, $ctime ); $line = implode('|', $log_arr); $this->_write_log('keyword', $line, $date); } /** * 二维码统计日志 * @access public * @param int $qrcode_id 二维码id * @param string $desc 二维码描述 * @param int $qrcode_type 二维码类型 1.扫码进入;2.扫码关注 */ public function qrcode($qrcode_id, $desc, $qrcode_type) { $ctime = date('YmdHis'); $log_arr = array( $this->_branch, $this->_merchant_id, $this->_merchant_code, $this->_userid, $this->_openid, $this->_phone, $qrcode_id, $desc, $qrcode_type ); $line = implode('|', $log_arr); $this->_write_log('qrcode', $line, $date); } /** * 获取服务器端IP地址 * @access public * @return string */ public function get_server_ip() { if (isset($_SERVER)) { if($_SERVER['SERVER_ADDR']) { $server_ip = $_SERVER['SERVER_ADDR']; } else { $server_ip = $_SERVER['LOCAL_ADDR']; } } else { $server_ip = getenv('SERVER_ADDR'); } return $server_ip; } /** * 写日志 * @access private * @param string $log_type 日志类型 * @param string $line 日志内容 * @param string $date 日志日期 */ private function _write_log($log_type, $line, $date) { $dir = dirname($this->_log_path); // 创建目录 if ( !file_exists($dir) ) { mkdir($dir, 0777); } // 获取服务器ip $ip = $this->get_server_ip(); $filename = "{$this->_log_path}/{$this->_merchant_code}_{$log_type}_{$ip}_{$date}.log"; @file_put_contents($filename, $line."\n", FILE_APPEND); } }
2. [文件] doc.tar.gz
以上就是利用phpdoc常用标签生成代码说明文档的内容,更多相关内容请关注PHP中文网(www.php.cn)!
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사
KB5055523을 수정하는 방법 Windows 11에 설치되지 않습니까?
4 몇 주 전ByDDD
KB5055518을 수정하는 방법 Windows 10에 설치되지 않습니까?
4 몇 주 전ByDDD
<garden> : 정원 재배 - 완전한 돌연변이 가이드
3 몇 주 전ByDDD
<gum> : Bubble Gum Simulator Infinity- 로얄 키를 얻고 사용하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
KB5055612 수정 방법 Windows 10에 설치되지 않습니까?
3 몇 주 전ByDDD

뜨거운 도구

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경