zend framework_v1 常见问题汇总

1、配置虚拟主机之后,Action无法正常工作,原因为没有开启AllowOverride。

初始配置:

<VirtualHost 127.0.0.1:80>
    DocumentRoot "E:/PHP/votesystem001/public"
    ServerName zendvote.com
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不允许别人修改我们的页面
    AllowOverride None
    #设置访问权限
    order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

修改为:

<VirtualHost 127.0.0.1:80>
    DocumentRoot "E:/PHP/votesystem001/public"
    ServerName zendvote.com
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不允许别人修改我们的页面
    AllowOverride All
    #设置访问权限
    order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

2、中文乱码问题

如果本网站的内容只是在国内公开,也就是说,只要支持中文即可,可以通过下面的设置解决中文乱码:

1>在mysql创建表的时候,写明编码为gbk;

CREATE TABLE `vote_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `ip` varchar(20) NOT NULL,
  `vote_date` bigint(20) NOT NULL,
  `item_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;

2>所用的代码编辑工具,设置编码为GBK;

3>初始化适配器的时候,指明为GBK;

$url = constant("APPLICATION_PATH").DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.'application.ini';
      $dbconfig = new Zend_Config_Ini($url,"mysql
      $db = Zend_Db::factory($dbconfig->db);
      $db->query('SET NAMES GBK');
      Zend_Db_Table::setDefaultAdapter($db);

完成以上三步之后,你的中文乱码问题,也就解决了。

总结:目的就是要保证编码要统一。

 

转载于:https://my.oschina.net/jackguo/blog/127601

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值