小编Mar*_*pel的帖子

出于性能原因,我应该使用SQL限制吗?

我正在使用Doctrine 2作为一个项目,它会有很高的流量,而且我很关心性能.

有时我会为了"分页"的目的加载很多实体.

示例:加载30,000篇已发表的文章,我需要对这些结果进行分页.

我想知道从我可以使用LIMIT OFFSET sql语句的数据库加载这么多行是多么糟糕,但是使用Doctrine 2和Pagination,实现Paginator适配器(复杂的存储库等)会有更多的开销.在哪里我可以使用一个简单的迭代器适配器.

我想有一个好的缓存系统,它不应该是一个问题,但我不是很确定.

顺便问一下,你有关于缓存的任何提示吗?

php performance caching limit doctrine-orm

3
推荐指数
1
解决办法
1169
查看次数

XMLHttpRequest引用者和iframe

页面A包含javascripts函数执行XMLHttpRequest.页面A加载页面B中的iframe.页面B执行parent.makeRequest()函数,该函数又执行XHR请求.我希望XHR请求的引用者/来源是页面B,但它是页面A.有没有什么办法解决这一问题?

javascript xmlhttprequest referer

3
推荐指数
1
解决办法
4935
查看次数

Curl post给出了像åäö这样的奇怪角色

我有一个带有后期操作的grails控制器.现在,当通过php和curl尝试发布到grails控制器时,我得到?了像åäö等等字符的占位符.如果我创建一个小的html表单,同样的帖子,grails控制器接收参数,åäö而不是?,等等.

下面的差异是什么?如何让curl充当html表单示例?

卷曲的例子:

$x = curl_init("http://localhost/post");      
curl_setopt($x, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));  
curl_setopt($x, CURLOPT_POST, 1);  
curl_setopt($x, CURLOPT_POSTFIELDS, "Foo=ö");  
curl_setopt( $x, CURLOPT_ENCODING, "UTF-8" );   
curl_setopt($x, CURLOPT_RETURNTRANSFER, 1);  
$data = curl_exec($x);   
curl_close($x);
Run Code Online (Sandbox Code Playgroud)

html表单示例:

<html> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head><title></title></head>
<body>
<form name="input" action="http://localhost/post" method="post" enctype="application/x-www-form-urlencoded">
<TEXTAREA NAME="Foo" COLS=10 ROWS=4 type=text>ö</TEXTAREA>
<input class="button" type="submit" value="send"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

php grails encoding curl

3
推荐指数
1
解决办法
6252
查看次数

阻止builtwith.com显示我的网站是用什么构建的

有没有办法掩盖我真正的服务器技术说从PHP到http://builtwith.com等网站检查时显示为Python ?或者至少不显示任何东西?

php security

3
推荐指数
1
解决办法
4532
查看次数

如何提取html注释和节点包含的所有html?

我正在创建一个小的网络应用程序来帮助我管理和分析我的网站内容,而cURL是我最喜欢的新玩具.我已经想出如何提取有关各种元素的信息,如何查找具有某个类的所有元素等,但我遇到了两个问题(见下文).我希望有一些漂亮的xpath答案,但如果我不得不诉诸正则表达式,我猜这没关系.虽然我对正则表达式不是那么好,所以如果你认为这是要走的路,我会欣赏这些例子......

相当标准的起点:

$ch = curl_init();
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_URL,$target_url);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    $html = curl_exec($ch);
    if (!$html) {
        $info .= "<br />cURL error number:" .curl_errno($ch);
        $info .= "<br />cURL error:" . curl_error($ch);
        return $info;
    }

    $dom = new DOMDocument();
    @$dom->loadHTML($html);

    $xpath = new DOMXPath($dom);
Run Code Online (Sandbox Code Playgroud)

和提取信息,例如:

// iframes
    $iframes = $xpath->evaluate("/html/body//iframe");
    $info .= '<h3>iframes ('.$iframes->length.'):</h3>';
    for ($i = 0; $i < $iframes->length; $i++) {
        // get iframe attributes
        $iframe …
Run Code Online (Sandbox Code Playgroud)

php xpath curl dom

3
推荐指数
1
解决办法
3937
查看次数

在NOT IE时使用样式表

当我使用此代码

<!--[if IE 6]>
<link rel="stylesheet" href="ie6.css" type="text/css" />
<![endif]-->

<!--[if !IE]>
<link rel="stylesheet" href="not_ie.css" type="text/css" />
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

IE 6确实正确使用了指定的样式表,但所有其他浏览器都忽略了它们何时应该使用基本陈述的样式表,如果你不是IE,则使用这个样式表.

有任何想法吗?

css internet-explorer

2
推荐指数
1
解决办法
1524
查看次数

最大化浮动div?

假设我有2个div并排:1个向左浮动,另一个向右浮动.现在说我将左浮动div的大小修改为200px.如何强制右浮动div"自动"最大化或占用水平屏幕空间的其余部分(无论浏览器窗口的大小如何?

html css

2
推荐指数
1
解决办法
3285
查看次数

如何将默认值放入"输入",当用户按下输入时,它将消失?

如何将默认值输入到用户按下输入时它会消失?

我的代码不起作用:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
    <input  value="default-value" type="text"/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript css

2
推荐指数
1
解决办法
465
查看次数

如何用外部HTML替换整个HTML?

假设我有这个页面(page.html):

<html>
    <body>
    <h1>AAA</h1>
<script type="text/javascript">
    //<![CDATA[
$(document).ready(function() {

 $.get('page2.html', function(data){
  // I want to replace the entire HTML with the HTML of page2.html
  // but this doesnt' work
  $('html').replaceWith(data);
 });

});    //]]>
</script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

另一页(page2.html):

<html>
    <body>
    <h1>BBB</h1>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

正如您在我的代码段中所看到的,我想从page2.html获取HTML并使用获取的响应替换page.html的整个内容.

怎么做?

javascript jquery

2
推荐指数
1
解决办法
1844
查看次数

用户点击它时隐藏(或禁用)提交按钮

我正在使用CakePHP框架开发应用程序.

我们都有客户在提交按钮上多次单击.

当用户点击它时,如何隐藏或(甚至更好地)禁用提交按钮?

在互联网上,我找到了几个可以做到的Javascripts,但我需要帮助将它集成到我的CakePHP脚本中.

javascript cakephp button

2
推荐指数
1
解决办法
3819
查看次数