如何申请google广告连联盟Google Adsense广告挣钱(转)

Google AdSense 是一种获取收入的快速简便的方法,适合于各种规模的网站发布商。它可以在网站的内容网页上展示相关性较高的 Google 广告,并且这些广告不会过分夸张醒目。由于所展示的广告同用户在您的网站上查找的内容相关,因此,最终您的内容网页不仅会为您带来经济效益,还能够得以充实。

一、注册Google AdSense

如果以前注册过Google AdWords(Google广告词——对关键字进行右侧付费推广)那么就能使用您的Google AdWords密码登录,开通Google AdSense了。

Google提示不支持中文,注册时填写拼音

需要填写

您输入的帐户信息如下:(XX代表隐藏站长的信息)

收款人:Wang Xiaobo或Xiaobo Wang(这个信息一定不能错,一旦提交永远不得更改。姓、名顺序可以按中文习惯,也可以按英语习惯颠倒过来)
地址:Room 102, Building 3
地址(延续):Hua Xi Cun 2#
城市:Nanjing
州、省或地区:Jiangsu
邮政编码:210000
国家/地区:中国
电话:+86-25-85412654(注意:国家代码和区号前不要加0)
产品:AdSense for content(针对内容的AdSense)和AdSense for search(针对搜索的AdSense)
网站:www.XXX.com
网站语言:中文(简体)

请在继续前确认所有信息都是正确的。
在此之后不能更改付款人姓名或国家/地区名称。

二、等待Google来信

等了两天,Google来信如下:

标题:欢迎光临_Google_AdSense
祝贺您!

您的 Google AdSense 申请已得到批准。现在,您可以启用帐户,几分钟后就会开始向您的网站投放 Google 广告和提供 AdSense for search (针对搜索的
AdSense)。

第 1 步:启用帐户。
请访问 https://www.google.com/adsense?hl=zh_CN,然后使用申请中所提交的电子邮件地址和密码登录到自己的帐户,并选择同意 AdSense 条款。

第 2 步:将 AdSense 代码粘贴到您的网页。
只需按照“广告布局代码”页和“搜索代码”页中的说明进行*作,即可将 Google 代码复制并粘贴到您的网站中。几分钟后就会开始向您的网站投放 Google 广告和提
供 AdSense for search。

第 3 步:查看结果。
广告开始投放后,您就可以通过自己帐户中的在线报告随时查看收入情况。请注意,如果您的网站中包含以下任一内容,都有可能无法从 AdSense 中获得最大收
入:
* robots.txt
* 框架
* 表单与动态内容
* 过多的图像
* 要求登录和输入密码

有关针对此计划优化网站的更多技术指南与建议,请访问:
https://www.google.com/adsense/faq-tech?hl=zh_CN

重要注意事项:
* 如果 Google 尚未抓取您的网站,则可能需要数小时才能看到有针对性的广告。
您在此期间可能会看到公益广告(这些广告无法为您带来任何收入)。

* 如果您的网页还未列入 Google 搜索的索引中,Google 将不能返回SiteSearch 结果。请注意将 SiteSearch 添加至任何网页,都不会使此网页进入我们漫游器的等待抓取队列。如果您希望采用手动方式将贵网站的主要网址添加到我们的抓取索引,则可以通过

http://www.google.com/intl/zh-CN/addurl.html
进行这一*作。采用这一方式提交贵网站不能确保网站一定会被加入到 Google 索引中。

* 网站发布商或由发布商征召的第三方不得采用人为方式或通过漫游器产生欺诈性
点击(恶意点击)。点击自己网站上的广告有违此政策,所以请不要因任何原因点
击这些广告。我们会监控所有的 AdSense 活动,并且会停用违反此政策的任何发
布商的帐户。详细信息,请参阅 Google AdSense 条款,地址是:
https://www.google.com/adsense/localized-terms?hl=zh_CN

有什么问题?
请随时与我们联系,我们的电子邮件地址是 adsense-zhs@google.com。

欢迎光临 Google AdSense。我们热切期盼能够帮助您全面发挥贵网站的创收潜力。

Google 小组敬上
三、登录设置,获取代码

为了让大家登录方便,首页放了个Google AdSense登录的地址,可以直接点击。

由于Google的中文意思表达不明确,并且Google对于很多细节都避而不谈,所以dan迷茫了两天。通过几天的试验和询问朋友,终于明白很多东西。

Google AdSense分为AdSense广告和AdSense搜索。AdSense广告就是放google的广告条;AdSense搜索就是提供个性化颜色的Google搜索,上面有时会出现广告条。也就是说,只有点击广告条才能赚钱,否则显示得再多也是徒劳!

进入“广告设置”栏目。可以设置“广告颜色”等细节,最后生成一段代码,比如

省略

然后你就粘贴到你的网页上就可以了。

在“搜索设置”栏目中,设置后又能得到一段代码
省略
同样,粘贴即可。

四、上传网页

上传后,并不能马上显示广告,有的可能要过段时间才行。有的则显示没有任何收入的公益广告!根据Google的流程来看是这样的:

网页执行JavaScript程序,Google服务器来抓当前的网页,然后Google服务器分析网页内容,在你的网页上显示相关的广告。看来Google AdSense的确很聪明。

五、查询收入

Google AdSense是每4个小时更新一次点击记录。加上美国时间比中国时间晚12小时,所以再查询时不要疑惑。前天有3个点击,前两个赚了0.44美元,第3个外国广告的点击居然有6美元!不过,昨天看了一下统计,居然变成了每个点击0.04美元。不知道Google的浮动算法是什么,Google对于AdSense的很多东西都是保密的。

六、Google AdSense支付

当你的广告费满100美元时,Google会寄支票给你。带上支票和身份证。另外带点钱(100元就够了),去中国银行办理光票托收手续(这种支票并不是那种凭身份证就能去银行取钱的那种,所以叫“光票”)。

首先,支票背面的指定位置需要你的签名,签名要和正面收款人的一致(别担心,银行工作人员都会告诉你的啦~~);

其次,您需要向银行交纳一定的手续费和支票的邮寄费(支票要寄到国外银行),所收费用根据各地情况而不同。邮寄费一般为10——12元人民币不等,手续费一般为支票金额的0.1%(不足10元按10元交纳);

再次,留下您的联系电话,将收据收好,大约1个月之后,银行会电话通知您款已到帐。

最后,拿着您的收据和身份证再到外币柜台,这时您就可以见到您的美元了!(注:如果直接把美圆存到银行,要比把美圆取出,然后再存的利率要高一些~~)

注意:有的公司的支票是有有效期的,所以要尽快办理托收手续!比如,票面上标注“VOID AFTER 90 DAYS”表示支票在90天内有效。
七、疑问

Q: Google同意将代码放到多个网站上吗?
A: 虽然申请时填了一个网址,但是Google给了你一段代码,里面有你的 ID号,所以可以放在多个网站上。

Q: 如何避免Goolge的公益广告?
A: 公益广告是不可避免的,Google允许你在应该显示公益广告时换成你自己的广告

Google广告联盟是现在信誉最好的广告提供商之一。

原文地址:http://www.williamlong.info/adsense/

Zend_Soap实战

以前没做过webservice,现在项目需要,只好边学边做,还好有google大神和baidu大哥帮助。
zf的框架很牛,做webservice基本不用动脑
只用到zend_soap包中的Zend_Soap_Server,Zend_Soap_AutoDiscover和Zend_Soap_Client三个类

首先要注意ZF是调用php的soap扩展,所以请确认php.ini(;extension=php_soap.dll 去掉分号)中打开了soap扩展,同时注意配置php.ini中soap段的wsdl缓存,调试时请关闭该缓存,否则
修改model后无法查看效果。发布时可以把缓存打开。还有就是使用服务器套件的问题,我试过使用APMServ5.2.6,完全正确的代码,就是使用

Zend_Soap_Client时无法获取服务端提供的服务函数,最后改用wapmserver又没有问题,哎。。。

基本流程就是使用使用Zend_Soap_Server,Zend_Soap_AutoDiscover构建服务端,然后使用Zend_Soap_Client来调用服务端提供的功能

基本代码
(1)服务端,先建立controller
/modules/services/controllers/WapSearchControllers.php
[php]
setClass(‘WapArticle’);
$autodiscover->handle();
}
private function handleSOAP() {
$soap = new Zend_Soap_Server($this->_WSDL_URI);
$soap->setClass(‘WapArticle’);
$soap->handle();
}
//不需要视图和layout,所以禁用之
public function init(){
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout()->disableLayout();
}

public function indexAction(){
//判断请求中是否有wsdl有就自动生成wsdl的uri否则启动soap服务
if(isset($_GET[‘wsdl’])) {
$this->handleWSDL();
} else {
$this->handleSOAP();
}
}
//客户端测试
public function clientAction(){
$client = new Zend_Soap_Client($this->_WSDL_URI);
//调用服务端提供的服务
$res = $client->getArticle(31);
var_dump($res);
}

}
[/php]
需要特别说明的是,这里的setClass成员函数传入的业务逻辑类名称一定要和下面的业务逻辑类名称一致,不然会报非法控制器错误

建完controllers该建model了
//业务逻辑所在层,把所有需要提供的服务都可以放在这一层中
/modules/services/models/models/WapArticle.php
[php]
getArticle($id);

//这里可以把结果进行xml格式化或者json格式化,以方便其他客户端调用
$d = json_encode($s);
return $d;
}

/**
* Simple array sort
*
* @param Array $array
* @return Array
*/
public function simple_sort($array) {
asort($array);
return $array;
}
/**
* Adds method
*
* @param Int $param1
* @param Int $param2
* @return Int
*/
public function math_addx($param1, $param2) {
return $param1+$param2;
}

}
?>
[/php]
这里要特别说明的是:

我曾尝试让WapArticle类直接继承Zend_Db_Table_Abstract类,然后再在WapArticle类中直接对数据库表操作,没有成功,报出非法控制器错误,不知

如何解决,google了一下,好像网上也有类似的问题,不知是ZF本身的问题,还是说我没写对,有哪位大神路过的话,还望给指点一二

然后我又尝试使用Zend_Registry::get(‘db’)获取数据库连接对象,也是为空,又失败,正当我一筹莫展时,突然想起尝试一下在该类中直接实例化一

个原来的的数据库表操作类试试(modules/news/models/FrontDbTable/Article.php),没想到还真成功了。不知道这个问题出在哪里!不过这样也好

。把这个层单独独立出来,只处理业务逻辑,数据库操作在另外一个层实现,倒实现了分离的目的,嘿嘿,算是无心插柳吧。

还有就是业务逻辑层的成员函数说明格式要注意,不然好像还会报出非法控制器错误(哎,啥都报这个错误,还让人活不。。。)
[php]
/**
* Adds method
*
* @param Int $param1
* @param Int $param2
* @return Int
*/
public function math_addx($param1, $param2) {
return $param1+$param2;
}
[/php]
函数名称说明与函数参数说中间有一行空格
输入要采用”@param 参数类型 参数名”的格式
输入要采用”@return 参数类型”的格式

顺便也贴上/modules/news/models/FrontDbTable/Article.php的代码
[php]
class News_Model_FrontDbTable_Article extends Zend_Db_Table_Abstract
{
protected $_name = ‘custom_article’;

public function getArticle($id)
{
$id = (int)$id;
$where = array(‘id=’.$id, ‘isshow=1’);
$row = $this->fetchRow($where);
if(!$row){
return 0;
}
return $row->toArray();
}
}
[/php]
下面就是如何使用了
有三个地址
http://192.168.1.100/kktapp/public/services/wapsearch/index?wsdl显示该server的wsdl,uri其中对服务做了详细描述包括服务名称,服务的类

型,输入输出参数等
而http://192.168.1.100/kktapp/public/services/wapsearch/index则可查看服务是否正常运行
一般出现如下界面就说明服务正常运行
[xml]




Sender
Invalid XML



[/xml]
http://192.168.1.100/kktapp/public/services/wapsearch/client则是客户端测试,当然也可以使用其他客户端(如java,.net等)进行测试
这里只测试了一个服务getArticle($id),数据库用户配置正确的话,应该返回一个json格式的数组

—————————————————————————–

用java写了客户端,测试了一下,还行能调用

使用到了axis1.4代码如下
[java]
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class Testserver {

public static void main(String[] args) {
try {
String endpoint = “http://192.168.1.100/kktapp/public/services/wapsearch/index”;
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName(“getArticle”);
int temp = 31;
String result = (String) call.invoke(new Object[] { temp });
System.out.println(“result is ” + result);
}
catch (Exception e) {
System.err.println(e.toString());
}
}

}
[/java]

分类: Php, ZEND FRAMEWORK(ZF)

如何在网页中启动本地应用程序

说到单点登录,往往是和Portal(门户)是离不开的。通常企业中会有许多应用,WEB的或CS的。而做Portal的时候往往是做成WEB的。这时候,用户登录Portal后,如何从Portal启动本地的CS程序,就成为需要解决的问题。
不知道大家是如何解决的,我的做法是,自己实现一个协议(就象迅雷/电驴/网络蚂蚁那样),在Portal上实现一个形如
[html]
协议名称://应用名称/作业?action=动作&param1=参数1&param2=参数2…
[/html]
这样的例子可能是(我们协议名是用公司简称,这里我就用foo):
[html]
<a href=”foo://erp/order?action=query&owner=hydonlee”>我的订单</a>
[/html]
通过这样的设计,让浏览器象处理http协议的链接一样,把请示发送给我们的应用。
那如何让浏览器将这个链接发送给我们的协议处理器呢?这就需要向系统中注册一下(Windows下),注册表如下:

[csharp]
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\foo]
@=”URL: foo Application 协议”
“URL Protocol”=””

[HKEY_CLASSES_ROOT\foo\DefaultIcon]
@=”d:\\workspace\\fooPortal\\bin\\client\\foo.protocolhandler.exe,1″

[HKEY_CLASSES_ROOT\foo\shell]

[HKEY_CLASSES_ROOT\foo\shell\open]

[HKEY_CLASSES_ROOT\foo\shell\open\command]
@=”\”d:\\workspace\\fooPortal\\bin\\client\\foo.protocolhandler.exe\” \”%1\””

[/csharp]
怎么样?是不是很简单?其实将这个加入注册表之后,你可以开始->运行,输入:foo://test/ 回车,来测试你的协议处理器了!windows系统会把网址作为参数提供给命令行。
注册协议处理器的C#代码如下,我是写在协议处理器的类中的:

[csharp]
private void FooProtocolRegister() {
// copyright(c) hydonlee, 转载请注明原址
RegistryKey cr = Registry.ClassesRoot;

RegistryKey Fookey = cr.CreateSubKey(“Foo”);

//添加Foo键
Fookey.SetValue(“”, “URL: Foo Application 协议”);
Fookey.SetValue(“URL Protocol”, “”);

//添加DefaultIcon
RegistryKey iconKey = Fookey.CreateSubKey(“DefaultIcon”);
iconKey.SetValue(“”, string.Format(“{0},1”, Application.ExecutablePath.ToLowerInvariant()));

//添加Shell Key
RegistryKey shellKey = Fookey.CreateSubKey(“shell”);
RegistryKey openKey = shellKey.CreateSubKey(“open”);
RegistryKey commandKey = openKey.CreateSubKey(“command”);
commandKey.SetValue(“”, string.Format(“\”{0}\” \”%1\””, Application.ExecutablePath.ToLowerInvariant()));

Fookey.Close();
}

[/csharp]
这样,由浏览器的链接,已经传递到我们本地的应用中了,剩下的事情就比较简单了。协议处理器分析这个地址,呼叫相应的作业插件,并将参数传入。
简单来说就是:通过协议地址模型,Portal生成链接->浏览器发起请求->协议处理器分派–>各应用插件启动作业

Zend Framework利用Zend_Cache生成页面缓存(页面静态化)

One of the things I’m always looking for is ways to improve performance with the applications I write. While a few applications are write-heavy, most are read-heavy: that is, reading the database is the predominant behavior (for example, this WordPress blog reads the database far more often than it writes to the database). Additionally, Zend Framework is (comparatively) slow at handling requests, offering a throughput of about 67 requests per second on my machine, while loading static pages came in at a whopping 750 requests per second.*

So, given this performance difference, how do we improve the performance of Zend Framework while still retaining its functionality and ease-of-use? Well, we employ caching, of course!

But not just any caching. One of the beauties of a read-heavy website, especially one that doesn’t change all that often, is that we have the ability to cache entire pages and serve them directly using our web server. In Zend Framework 1.10.0, Zend_Cache_Frontend_Capture and Zend_Cache_Backend_Static were introduced, giving us the ability to take entire pages produced by Zend Framework and cache them. This means that we get the ability to use Zend Framework and all of its framework-y goodness, while still having the ability to enjoy the performance of static HTML pages served by our webserver. Excellent.

When devising my proof of concept, however, I found that implementing these components is more difficult than it looks. This is in part because the documentation is lacking, and also in part that the documentation in some spots is wrong. But after a week of searching and a journey that consisted of reading a Jira ticket, filing one of my own, dealing with imperfect documentation, asking questions in #zftalk on Freenode, bugging Matthew Weier O’Phinney to the point where I’m sure he made a voodoo doll of me, bugging Pádraic Brady about the cache, and good old-fashioned trial and error, I’ve mastered the implementation of static whole-page caching in Zend Framework, and here is a tutorial of how to do it yourself.

Standard Disclaimer
This tutorial implements code found in the latest version of Zend Framework at the time it was written. That means Zend Framework 1.10.3. Future releases of Zend Framework may, from time to time, change the behavior of components discussed here. Any changes should be reviewed in the documentation.

Additionally, where caching is concerned, it’s never a good idea to cache authenticated pages. It’s also never a good idea to cache data that changes a lot. Finally, it’s never a good idea to cache pages that change based on inputs, like pages that you access via POST or PUT requests.

Getting Started
First things first: let’s talk a little bit about Zend Framework’s caching model and how Zend_Cache_Frontend_Capture and Zend_Cache_Backend_Static are different.

With most Zend caches, you can implement them using the factory() method – in fact, the documentation warns against doing it any other way. So, to implement a frontend file cache using an APC backend, you can do the following:
[php]
Zend_Cache::factory(‘File’, ‘APC’, $frontOps, $backOps);
[/php]
With the implementation of the Zend_Cache_Manager in 1.10, you can register your cache with the manager, and then access it directly from your controllers. However, if you try to implement the Zend_Cache_Frontend_Capture or Zend_Cache_Backend_Static caches in this fashion, it blows up entirely, and will ruin your day. This is because these caches (collectively known as the Static Cache) are designed to serve files directly from the webserver once the file is cached; this means two things in particular: first, the static cache’s ID is the request URI (which in turn is turned into hexadecimal to comply with Zend_Cache’s rules on IDs), and second, because in order to capture the data, the cache uses output buffering.

Therefore, implementation of the static cache is done through the application.ini file, as a resource plugin. Developers wishing to implement this cache must include the following lines in their application.ini files:
[php]
; Custom Caches (Adjustments To Default CacheManager)

resources.cacheManager.page.backend.options.public_dir = APPLICATION_PATH “/../public/cached”
resources.cacheManager.pagetag.backend.options.cache_dir = APPLICATION_PATH “/../data/cache/tags”
[/php]
This means that all of the cached data is stored in the public/cached directory; all the cache’s tags are stored in data/cache/tags. These paths are by no means the only paths, but you must specify a path for both in order for the cache to work properly.

Why do you need to specify a separate tags directory? Due to the fact that files are served directly off the web server, rather than through PHP, the tags are stored separately in another cache. This defaults to a file cache, and you must specify another location for the files to be stored. The static cache utilizes an internal cache which is transparent to you in every other way.

There is one additional INI setting we must employ. In order to operate properly, the static cache employs output buffering and captures that output, writing it to disk and then serving it to the end user. Zend Framework also employs output buffering, which if not turned off, will interfere with the static cache. This was a hangup for me, since it’s not mentioned anywhere, and was something I discovered quite by accident. In order to turn off Zend Framework’s standard output buffering, we need to include the following INI directive:
[php]
resources.frontController.params.disableOutputBuffering = true
[/php]
This directs the front controller to turn off output buffering, which allows the static cache to handle it.

The last thing we need to do is create the directories where the cache will store its files, and make them owned by the web server user. While the static cache will create its own directory to store the cached static files (if it doesn’t exist), the file cache will throw an exception.

At this point, the file cache is ready to go. It’s configured, we’ve created the directories, we’ve turned off output buffering, and we’re not ready to get into caching files.

Caching Output

Zend Framework now has a built in cache helper which we’ll use to cache our static content. This needs to be done in the init() method (from my tests), and should list all the actions on the page you want to cache. Your controller should look similar to this:
[php]
< ?php class IndexController extends Zend_Controller_Action { public function init() { $this->_helper->cache(array(‘index’), array(‘indexaction’));
$this->_helper->cache(array(‘viewpage’), array(‘viewpageaction’));
}

public function indexAction()
{
}

public function viewpageAction()
{
}

public function logoutAction()
{
}
}
[/php]
The argument list for the cache plugin is simple: first, an array of the actions we’re caching, followed by an array of the tags associated with those actions. I’ve listed index and viewpage separately, with different tags, but you can tag multiple actions with the same tags, or break it out as I have. As you develop your application, you’ll want to be careful to not cache actions that are being executed on a POST request, which you can do by using the request object’s isPost() method. Also, in this example, logoutAction() is never cached; this is because we obviously don’t want to cache the results of a log out; we actually want PHP to unset the user’s identity.

Occasionally you may wish to invalidate the cache and remove old files. To do so, you search by tag. For this example, let’s purge the “indexaction” tagged files from the cache:
[php]
$this->_helper->getHelper(‘Cache’)
->removePagesTagged(array(‘indexaction’));
[/php]
The “indexaction” tagged pages will be invalidated and re-cached on the next request.

Directing Apache To Serve Cached Files
The whole point of this process is to serve the cached files at a significant performance improvement, so now we need to make some edits to our .htaccess file’s rewrite rules. The documentation’s rules are slightly incorrect, so let’s devise our own scheme.

My read-heavy sites are usually fairly simple, serving static HTML files rather than XML, OPML, or JSON. Therefore, I need only have a rule for HTML. Additionally, I want to make sure the web server only serves cached files on GET requests, so I’ll include a rewrite condition to help with that.
[php]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
RewriteRule ^/*$ cached/index.html [L]

RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.html -f
RewriteRule .* cached/%{REQUEST_URI}\.html [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^.*$ index.php [NC,L]
[/php]
These rules do a few things: first, if the request goes to the index controller with no arguments (www.example.com/) then it tries to load the index.html cached file. Second, if there are arguments it tries to load the cached file based on the request URI. Finally, for anyone used to using Zend Framework, the last five lines are the same five lines we start with in our Zend Framework default project; these we leave alone to ensure that we run the application if there is nothing in our cache to serve.

Final Notes On Caching
Now that we’ve gotten the cache set up and verified that it works, we can develop our application. However, we obviously want to avoid caching during development, so we can turn caching off by adding the following to our [development : production] section of application.ini:
[php]
resources.cacheManager.page.backend.options.disable_caching = true
[/php]
And that’s it! We can now develop our application with full page caching, getting the performance of a static web server and the flexibility of Zend Framework in the same package.

Good luck!

* The benchmarks cited were performed in the following way: I used Apache Bench, with 3000 requests (none concurrently), to test a stock Zend Framework project, and a flat file of the stock index.php of a Zend Framework project. Both times the files were named with the PHP extension. I did not benchmark the performance of any Zend components. The tests were executed on the same server as the webserver. Apache was restarted after each test. As usual, the standard disclaimers apply and the point of these benchmarks is simply to illustrate a well-known fact: flat HTML files serve faster than parsed PHP code.

原文链接:http://www.brandonsavage.net/caching-for-efficiency-with-zend-framework/

Zend Framework路由器设置方法

路由是个过程,在这个过程中它取出URI的端点(跟着基本URL的URI的那部分)并把它分解成参数来决定哪个模块、哪个控制器和控制器中的哪个动作应该接受请求。模块、控制器、动作和其它参数被打包到Zend_Controller_Request_Http对象,接着这个对象由Zend_Controller_Dispatcher_Standard来处理。路由只发生一次:当请求最初被接收和第一个控制器被派遣之前。

一般地,更新配置文件比修改代码更方便。这个可能通过addConfig()方法来做。基本上,你创建一个Zend_Config-compatible配置,并在你的代码中读入然后传递给RewriteRouter。

本例中,使用INI文件进行路由器配置。下面为具体代码。

[php]
/*
* Bootstrap.php
*/

protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$config = new Zend_Config_Ini(APPLICATION_PATH.’/configs/route.ini’, ‘production’);
$router->addConfig($config, ‘routes’);
}
[/php]

[shell]
[production]
routes.archive.type = “Zend_Controller_Router_Route_Regex”
routes.archive.route = “archive/(\d+)”
routes.archive.defaults.controller = “archive”
routes.archive.defaults.action = “show”
routes.archive.map.1 = “year”
routes.archive.reverse = “archive/%d”
[/shell]

Zend Framework提供的路由器功能十分强大,设置起来非常灵活。对于路由器的各种用法,在Zend Framework参考手册中有非常详细的介绍,大家可以参看:
《标准路由器 – Zend Framework Manual》

在移动设备浏览器上利用Bootstrap禁用网页缩放

在移动设备浏览器上,通过为viewport meta标签添加user-scalable=no可以禁用其缩放(zooming)功能。这样禁用缩放功能后,用户只能滚动屏幕,就能让你的网站看上去更像原生应用的感觉。注意,这种方式我们并不推荐所有网站使用,还是要看你自己的情况而定!

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>