我想使用标题中列出的框架之一,但我害怕选择错误的框架,因为我对框架知之甚少.我很了解PHP,但每次创建一个网站时我花了太多时间创建自己的小框架.事实上,我害怕使用框架,因为害怕陷入无法处理高流量网站的僵化和缓慢的框架.
哪个框架最能解决我的恐惧?
我有一个基于Codeigniter 1.7.2的PHP应用程序,目前正在生产和现场,似乎有严重的内存泄漏.
通过查看服务器上的"top",内存泄漏很明显:
top - 23:42:13 up 26 days, 10:14, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 54 total, 1 running, 53 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 7872040k total, 929748k used, 6942292k free, 142464k buffers
Swap: 0k total, 0k used, 0k free, 214420k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
22740 apache 15 0 308m 63m 5976 S 0 0.8 0:14.05 httpd
22733 apache …Run Code Online (Sandbox Code Playgroud) 我正在设计一个功能齐全的网站,其中包含主页上的博客.我希望它是全功能的,但我不想花费永远编码.有没有可以轻松与CodeIgniter集成的好博客系统?
我在Ubuntu 10(LAMP)上有Codeigniter.我有一个htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dort
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php
#controller, previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /dort/index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends
#the request to …Run Code Online (Sandbox Code Playgroud) 我有一个从表中检索所有标签的函数:
function global_popular_tags() {
$this->db->select('tags.*, COUNT(tags.id) AS count');
$this->db->from('tags');
$this->db->join('tags_to_work', 'tags.id = tags_to_work.tag_id');
$this->db->group_by('tags.id');
$this->db->order_by('count', 'desc');
$query = $this->db->get()->result_array();
return $query;
}
Run Code Online (Sandbox Code Playgroud)
我有另一张名为'work'的表.'work'表有一个'draft'列,其值为1或0.我希望COUNT(tags.id)考虑具有特定标记的工作是否处于草稿模式(1).
比如,有10件作品被标记为"设计".COUNT将是10.但是这些工作中有2个处于草稿模式,因此COUNT应该是8.如何管理?
我知道我可以使用以下web.config代码删除url的'index.php'部分:
<rewrite>
<rules>
<rule name="Rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)
问题是我在子目录(mydomain.com/codeigniter)中安装了CI,并且我无法理解web.config文件.
你知道怎么改变它,所以它适用于子目录吗?
谢谢 :)
我是Codeigniter的新手,我希望在验证失败后重定向到控制器:
if(!validate)
{
redirect('/poll/list');
}
Run Code Online (Sandbox Code Playgroud)
但我需要传递一个变量,$error以显示一些错误指示,但我不知道如何将参数传递给redirect方法中URL helper,并且想法?
我想用@ mywork.com限制我的电子邮件注册我在My_Form_validation中做了以下内容.
public function email_check($email)
{
$findme='mywork.com';
$pos = strpos($email,$findme);
if ($pos===FALSE)
{
$this->CI->form_validation->set_message('email_check', "The %s field does not have our email.");
return FALSE;
}
else
{
return TRUE;
}
}
Run Code Online (Sandbox Code Playgroud)
我用它如下.我对用户名和密码使用CI规则,它适用于电子邮件,它接受任何电子邮件地址.任何我感谢任何帮助.
function register_form($container)
{
....
....
/ Set Rules
$config = array(
...//for username
// for email
array(
'field'=>'email',
'label'=>$this->CI->lang->line('userlib_email'),
'rules'=>"trim|required|max_length[254]|valid_email|callback_email_check|callback_spare_email"
),
...// for password
);
$this->CI->form_validation->set_rules($config);
Run Code Online (Sandbox Code Playgroud) 最近我用Curl将我的抓取代码移动到了CodeIgniter.我正在使用来自http://philsturgeon.co.uk/code/codeigniter-curl的 Curl CI库.我把抓取过程放在一个控制器中,然后我发现我的抓取的执行时间比我在普通PHP中构建的执行时间要慢.
CodeIgniter输出结果需要12秒,而普通PHP只需要6秒.两者都包括HTML DOM解析器的解析过程.
这是我在CodeIgniter中的Curl代码:
function curl($url, $postdata=false)
{
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$this->curl->create($url);
$this->curl->ssl(false);
$options = array(
'URL' => $url,
'HEADER' => 0,
'AUTOREFERER' => true,
'FOLLOWLOCATION' => true,
'TIMEOUT' => 60,
'RETURNTRANSFER' => 1,
'USERAGENT' => $agent,
'COOKIEJAR' => dirname(__FILE__) . "/cookie.txt",
'COOKIEFILE' => dirname(__FILE__) . "/cookie.txt",
);
if($postdata)
{
$this->curl->post($postdata, $options);
}
else
{
$this->curl->options($options);
}
return $this->curl->execute();
}
Run Code Online (Sandbox Code Playgroud)
非codeigniter(纯PHP)代码:
function curl($ url,$ binary = false,$ …
PHP框架"CodeIgniter"提供了一个Session类,它不使用本机PHP-Sessions.相反,他们使用Cookies开发了自己的Session系统.
在他们的网站CodeIgniter.com上,他们写了以下内容:
Note: The Session class does not utilize native PHP sessions. It generates its own session data, offering more flexibility for developers.
Run Code Online (Sandbox Code Playgroud)
如下所述,最多只能保存4KB.
Note: Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The encryption process in particular produces a longer data string than the original so keep careful track of how much data you are storing.
Run Code Online (Sandbox Code Playgroud)
那么,这如何为程序员提供更多的灵活性呢?开发人员不使用本机PHP会话的实际原因是什么?
感谢您的信息!
codeigniter ×10
php ×7
.htaccess ×1
activerecord ×1
apache ×1
blogs ×1
cakephp ×1
cookies ×1
curl ×1
iis ×1
memory ×1
memory-leaks ×1
mysql ×1
performance ×1
rewrite ×1
session ×1
sql ×1
symfony1 ×1
ubuntu ×1
validation ×1
windows ×1