搜索
首页php教程PHP源码利用phpdoc常用标签生成代码说明文档

利用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(&#39;YmdHis&#39;);
        $log_arr = array(
                $this->_branch, 
                $this->_merchant_id, 
                $this->_merchant_code, 
                $this->_userid, 
                $this->_openid, 
                $this->_phone, 
                $opt_code, 
                $ctime,
                $act_code
                );
 
        $line = implode(&#39;|&#39;, $log_arr);
        $this->_write_log(&#39;operate&#39;, $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(&#39;YmdHis&#39;);
        $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(&#39;|&#39;, $log_arr);
        $this->_write_log(&#39;visit&#39;, $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(&#39;YmdHis&#39;);
        $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(&#39;|&#39;, $log_arr);
        $this->_write_log(&#39;activity&#39;, $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(&#39;YmdHis&#39;);
        $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(&#39;|&#39;, $log_arr);
        $this->_write_log(&#39;menu&#39;, $line, $date); 
    }
 
    /**
     * 关键词统计日志
     * @access public
     * @param string $keyword 关键词
     */
    public function keyword($keyword) {
        $ctime = date(&#39;YmdHis&#39;);
        $log_arr = array(
                $this->_branch, 
                $this->_merchant_id, 
                $this->_merchant_code, 
                $this->_userid, 
                $this->_openid, 
                $this->_phone, 
                $keyword, 
                $ctime
                );
        $line = implode(&#39;|&#39;, $log_arr);
        $this->_write_log(&#39;keyword&#39;, $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(&#39;YmdHis&#39;);
        $log_arr = array(
                $this->_branch, 
                $this->_merchant_id, 
                $this->_merchant_code, 
                $this->_userid, 
                $this->_openid, 
                $this->_phone, 
                $qrcode_id, 
                $desc, 
                $qrcode_type
                );
        $line = implode(&#39;|&#39;, $log_arr);
        $this->_write_log(&#39;qrcode&#39;, $line, $date);
    }
 
    /**
     * 获取服务器端IP地址
     * @access public
     * @return string
     */
    public function get_server_ip() { 
        if (isset($_SERVER)) { 
            if($_SERVER[&#39;SERVER_ADDR&#39;]) {
                $server_ip = $_SERVER[&#39;SERVER_ADDR&#39;]; 
            } else { 
                $server_ip = $_SERVER[&#39;LOCAL_ADDR&#39;]; 
            }   
        } else { 
            $server_ip = getenv(&#39;SERVER_ADDR&#39;);
        }   
 
        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常用标签生成代码说明文档doc.tar.gz


以上就是利用phpdoc常用标签生成代码说明文档的内容,更多相关内容请关注PHP中文网(www.php.cn)!


声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。