You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< ? php
namespace LaneWeChat ;
/**
*
* 自动载入函数
* Created by Lane.
* User: lane
* Date: 14-10-15
* Time: 下午6:13
* E-mail: lixuan868686@163.com
* WebSite: http://www.lanecn.com
*/
class Autoloader {
const NAMESPACE_PREFIX = 'LaneWeChat\\' ;
/**
* 向PHP注册在自动载入函数
*/
public static function register (){
spl_autoload_register ( array ( new self , 'autoload' ));
}
/**
* 根据类名载入所在文件
*/
public static function autoload ( $className ){
$namespacePrefixStrlen = strlen ( self :: NAMESPACE_PREFIX );
if ( strncmp ( self :: NAMESPACE_PREFIX , $className , $namespacePrefixStrlen ) === 0 ){
$className = strtolower ( $className );
$filePath = str_replace ( '\\' , DIRECTORY_SEPARATOR , substr ( $className , $namespacePrefixStrlen ));
$filePath = realpath ( __DIR__ . ( empty ( $filePath ) ? '' : DIRECTORY_SEPARATOR ) . $filePath . '.lib.php' );
if ( file_exists ( $filePath )){
require_once $filePath ;
} else {
echo $filePath ;
}
}
}
}
命名空间声明: namespace LaneWeChat\Core ; 定义了类的命名空间, 表明这个类属于LaneWeChat模块的核心部分。
类定义: class Menu 定义了一个用于管理微信自定义菜单的类。
setMenu方法: 用于创建自定义菜单。处理菜单数据, 将一维数组转换为树形结构, 支持子菜单, 并发送POST请求到微信服务器。
getMenu方法: 用于获取当前公众号的自定义菜单信息。发送GET请求到微信服务器。
delMenu方法: 用于删除当前公众号的自定义菜单。发送GET请求到微信服务器
命名空间声明: namespace LaneWeChat\Core ; 定义了类的命名空间, 表明这个类属于LaneWeChat模块的核心部分。
类定义: class Menu 定义了一个用于管理微信自定义菜单的类。
setMenu方法: 用于创建自定义菜单。处理菜单数据, 将一维数组转换为树形结构, 支持子菜单, 并发送POST请求到微信服务器。
getMenu方法: 用于获取当前公众号的自定义菜单信息。发送GET请求到微信服务器。
delMenu方法: 用于删除当前公众号的自定义菜单。发送GET请求到微信服务器