php教程|php手册
学习,typecho,主题,开发,笔记,学习,typecho,主题,开发,笔记,博客,被,加速,乐坑,掉,于是,了,的
php教程-php手册
学习typecho主题开发笔记01,typecho主题笔记01
smtp服务器源码,ubuntu无法识别win,tomcat jsp一键,python爬虫清单,php定义类构造函数,海鸥seolzw
博客被加速乐坑掉,于是有了学习typecho主题开发的想法,感谢这个机会!
外链平台源码,ubuntu中途卡顿,tomcat项目发布不上去,电脑端爬虫,php mysql页面展示,邯郸互联网seo推广如何进行lzw
首先是去看主题文件夹下面的’index.php’,一个博客的文章页面一般包括下面几个基本元素
电信宽带网站源码,ubuntu找不到光驱,双核4g tomcat并发,豆瓣读书python爬虫,php中属于代码执行的危险函数,seo命令教程lzw
作者
发表时间
文章分类 1 need(‘header.php’);
13 ?>
14
15
16next()): ?>
17 class=”post” itemscope itemtype=”/BlogPosting”>
18
$this->permalink() ?>”>title() ?>
19
20 $this->author->permalink(); ?>” rel=”author”>author(); ?>
21 <time datetime="date(‘c’); ?>” itemprop=”datePublished”>date(‘F j, Y’); ?>
22 category(‘,’); ?>
23 $this->permalink() ?>#comments”>commentsNum(‘评论’, ‘1 条评论’, ‘%d 条评论’); ?>
24
25
26 content(‘- 阅读剩余部分 -‘); ?>
27 28
29
30
31pageNav(‘« 前一页’, ‘后一页 »’); ?>
32
33
34 need(‘sidebar.php’); ?>
35 need(‘footer.php’); ?
下面是这是index.php的源代码:
1 need(header.php);13 ?>14 15
16next()): ?>17 itemscope itemtype="/BlogPosting">18
$this->permalink() ?>">title() ?>19 20 $this->author->permalink(); ?>" rel="author">author(); ?>21 <time datetime="date(c); ?>" itemprop="datePublished">date(F j, Y); ?>22 category(,); ?>23 $this->permalink() ?>#comments">commentsNum(评论, 1 条评论, \%d 条评论); ?>24 25
26 content(- 阅读剩余部分 -); ?>27
28 2930 31pageNav(« 前一页, 后一页 »); ?>32
33 34 need(sidebar.php); ?>35 need(footer.php); ?>
2-9行是注释,里面包含了主题的各种信息,每行以*开头。
@package 表示主题的名称
@author 表示作者信息
@version 表示主题当前的版本
@link 表示作者的网站链接
include()方法用来包含要用到的php文件,具体用法查阅PHP官方手册include()方法
在12,34,35行都能看到$this->need(),它在typecho里面就和include()的作用是一样的
$this->need(header.php);need(sidebar.php); ?>need(footer.php); ?>
所以上面的代码就是调用header.php,sidebar.php,footer.php。具体这三个php文件是什么作用的,很简单,顾名思义哦!
然后就是文章页面的主体了
next()): ?> itemscope itemtype="/BlogPosting">
$this->permalink() ?>">title() ?> $this->author->permalink(); ?>" rel="author">author(); ?> <time datetime="date(c); ?>" itemprop="datePublished">date(F j, Y); ?> category(,); ?> $this->permalink() ?>#comments">commentsNum(评论, 1 条评论, \%d 条评论); ?>
content(- 阅读剩余部分 -); ?>
pageNav(« 前一页, 后一页 »); ?>
endwhile是什么鬼????为什么我重来没用过….查阅了下资料,原来是一种语法糖:)
文章主体就是从这里开始到结束的
next()): ?>
:替代了{
;替代了}
详细见文章:PHP中流程控制的替代语法
接着就是一些方法了
permalink() ?>文章所在的连接title() ?>文章标题author(); ?>文章作者author->permalink(); ?>文章作者地址date(F j, Y); ?>文章的发布日期,格式可参考PHP日期格式category(,); ?>文章所在分类commentsNum(\%d Comments); ?>文章评论数及连接content(Continue Reading...); ?>文章内容,其中的“Continue Reading…” 是显示摘要时隐藏部分的文字
_e()这是什么方法,专一而精十
看了下wordpress里面的_e()方法,居然是用作翻译的。。。难道typecho还有歪果仁使用(逃
直接打印输出到 html 中的字符串,就用 _e() 。具体看这里
在代码里面还能看见itemprop属性,这是html5新加的,暂时不用管他Q.Q
最后是一个分页的方法
pageNav(); ?>
至此,index.php文件已经被分析一遍了,虽然我没有php基础,但是学习了之后发现不难,嘿嘿!继续努力!