php-header-跳转
- 五月 4th, 2012
header('HTTP/1.1 301 Moved Permanently');
header('Location:index.html');
$(document).ready(function()
{
alert($(window).height()); //浏览器当前窗口可视区域高度
alert($(document).height()); //浏览器当前窗口文档的高度
alert($(document.body).height());//浏览器当前窗口文档body的高度
alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin
alert($(window).width()); //浏览器当前窗口可视区域宽度
alert($(document).width());//浏览器当前窗口文档对象宽度
alert($(document.body).width());//浏览器当前窗口文档body的高度
alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin
}
)
典型的为文章的tag
首先看下效果图:

schema:
article:
actAs: { Timestampable: ~ }
columns:
title:
type: string(255)
notnull: true
body:
type: clob
notnull: true
relations:
tags:
class: tag
refClass: tagArticle
local: article_id
foreign: tag_id
foreignAlias: articles
tag:
columns:
name:
type: string(30)
tagArticle:
columns:
tag_id: { type: integer, primary: true }
article_id: { type: integer, primary: true }
relations:
tag: { onDelete: CASCADE, local: tag_id, foreign: id }
article: { onDelete: CASCADE, local: article_id, foreign: id }
data:
tag.yml
tag:
t1:
name: php
t2:
name: java
t3:
name: c
t4:
name: mysql
t5:
name: python
article.yml
article:
a1:
title: 论php的发展史
body: ......
tags: [t1, t2]
a2:
title: web开发的未来
body: ......
tags: [t2, t3, t4, t5]
cli:
symfony doctrine:build –all –no-confirmation
symfony generate:module frontend article
action:
$this->articles = Doctrine_Core::getTable('article')->getList();
model:
return $this->createQuery('a')->execute();
view -> indexSuccess:
<ul> <?php foreach($articles as $article): ?> <li> <div class="article"> <div><b>title:</b><?php echo $article->getTitle(); ?></div> <div> <b>Tag:</b> <ul> <?php foreach($article->getTags() as $tag): ?> <li><?php echo $tag->getName(); ?></li> <?php endforeach; ?> </ul> </div> </div> </li> <?php endforeach; ?> </ul>
layout里面使用include_slot后,会在标题里面多出来一个数字1
这个问题是因为include_slot是不需要echo的,如果使用了echo的话就会在后面出现一个数字1
正确的用法为:
<title><?php include_slot('title', "我的symfony网站"); ?></title>
粗心啊 不细心啊…
节点方法
接下来看看所有节点都具有的方法(与节点属性一样,我省略了实际上不适用于多数 HTML DOM 操作的少数方法):
节点的属性
使用 DOM 节点时需要一些属性和方法,因此我们首先来讨论节点的属性和方法。DOM 节点的属性主要有:
XMLHttpRequest 对象有一个名为 readyState 的属性
0:请求未初始化(还没有调用 open())。
1:请求已经建立,但是还没有发送(还没有调用 send())。
2:请求已发送,正在处理中(通常现在可以从响应中获取内容头)。
3:请求在处理中;通常响应中已有部分数据可用了,但是服务器还没有完成响应的生成。
4:响应已完成;您可以获取并使用服务器的响应了。
IBM的详细介绍连接:http://www.ibm.com/developerworks/cn/xml/wa-ajaxintro3/
主要学习了浏览器的不一致性
在对这个过程有一个基本的了解之后,请试着从几个不同的浏览器中访问您的页面。您应该会注意到各个浏览器如何处理这些就绪状态并不一致。例如,在 Firefox 1.5 中,您会看到以下就绪状态:
1
2
3
4
这并不奇怪,因为每个请求状态都在这里表示出来了。然而,如果您使用 Safari 来访问相同的应用程序,就应该看到 —— 或者看不到 —— 一些有趣的事情。下面是在 Safari 2.0.1 中看到的状态:
2
3
4
Safari 实际上把第一个就绪状态给丢弃了,也并没有什么明显的原因说明为什么要这样做;不过这就是 Safari 的工作方式。这还说明了一个重要的问题:尽管在使用服务器上的数据之前确保请求的状态为 4 是一个好主意,但是依赖于每个过渡期就绪状态编写的代码的确会在不同的浏览器上得到不同的结果。
例如,在使用 Opera 8.5 时,所显示的就绪状态情况就更加糟糕了:
3
4
最后,Internet Explorer 会显示如下状态:
1
2
3
4
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
初始化XMLHttpRequest的方法有很多,无外乎火狐和IE
IBM帮助信息:XMLHttpRequest 惟一的目的是让您发送请求和接收响应
function inject_check($sql_str) {
return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str);
}
function verify_id($id=null) {
if(!$id) {
exit('没有提交参数!');
} elseif(inject_check($id)) {
exit('提交的参数非法!');
} elseif(!is_numeric($id)) {
exit('提交的参数非法!');
}
$id = intval($id);
return $id;
}
function str_check( $str ) {
if(!get_magic_quotes_gpc()) {
$str = addslashes($str);
}
$str = str_replace("_", "\_", $str);
$str = str_replace("%", "\%", $str);
return $str;
}
function post_check($post) {
if(!get_magic_quotes_gpc()) {
$post = addslashes($post);
}
$post = str_replace("_", "\_", $post);
$post = str_replace("%", "\%", $post);
$post = nl2br($post);
$post = htmlspecialchars($post);
return $post;
}
一个网页要有良好的404页面
404页面不单要设计用户可以看到的元素,还要设计可以让蜘蛛看到的元素。
php中用header.
例如:
//header("HTTP/1.0 404 Not Found");
header("HTTP/1.0 500 Internal Server Error");
exit;
所有的HTTP code:https://www.kulouxia.com/view/2012-03-02/header-http-code.html