小编use*_*000的帖子

如何从Symfony的HttpFoundation组件中检索基本身份验证凭据?

我想从Symfony的HttpFoundation组件中检索基本身份验证凭据.粗略地看一下文档什么都没有透露; 我有办法吗?

(我在不基于Symfony框架的应用程序中使用HttpFoundation组件.)

php symfony symfony-http-foundation

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

无法在Windows/Cygwin上使用perl确定文件创建时间

我写这个是为了找出给定文件的文件创建时间:

#!/usr/bin/perl
use strict;
use warnings;

use File::stat;

open (my $fh, '<', "abc.txt") or die "$!";
my $t = (stat($fh))[9];
print $t;
Run Code Online (Sandbox Code Playgroud)

但是,这不起作用,并给出:

Use of uninitialized value $t in print at ./tests.plx line 9.
Run Code Online (Sandbox Code Playgroud)

谁能指出我在这里做错了什么?或者这不能在Windows/Cygwin上的perl(5.14.2)上完成,我必须选择一些替代方法吗?

提前致谢.

windows perl cygwin file

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

浮点数仅打印整数部分

我有一个这样的程序:

#include <iostream>
using namespace std;

int main ()
{
    double x;
    for (int i = 1; i < 100; i++)
    {
        cout << (x = i/100) << endl;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在运行它时,我只得到:

0
0
0
[...]
Run Code Online (Sandbox Code Playgroud)

我在Cygwin-g ++和MinGW-g ++上测试了这个; 版本4.7.2.哪里可能是问题?

c++ floating-point

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

"标题前脚本输出结束" - Apache上的CGI

我有以下CGI脚本:

#!c:\cygwin\bin\perl.exe

use CGI qw(:standard);

my $query = $CGI->new;

print header (
  -type   => "text/html",
  -status => "404 File not found"
);

print "<b>File not found</b>";
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误:

Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
End of script output before headers: test.cgi

If you think this is a server error, please contact the webmaster.
Error 500
127.0.0.1
Apache/2.4.10 (Win32) OpenSSL/1.0.1h PHP/5.4.31
Run Code Online (Sandbox Code Playgroud)

我已经看过这个(和其他类似的)问题,但是标题没有被print编辑,而不是我的.

我正在使用Cygwin Perl的XAMPP Windows软件包.

有人可以帮忙吗?谢谢.

apache perl cgi

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

为正则表达式获取太多匹配

我在JS写了一个正则表达式测试器.但是,似乎对于某些正则表达式,我得到多个匹配.

例如,如果对于内容hello, world,hello.*给出正则表达式,则报告它匹配hello, world.但是,如果正则表达式现在设置为(hello|goodbye).*然后报告的匹配是hello, worldhello,而它应该hello, world只是.

<!DOCTYPE html>
<html>
    <head>
        <title>Regex tester</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <script type="text/javascript">
            function resetform() {
                document.getElementById("results").innerHTML = "";
            }

            function escapetags(str) {
                return (str.replace('&','&amp;').replace('<', '&lt;').replace('>', '&gt;'));
            }

            function check() {
                if (!document.form1.re.value) {
                    document.getElementById("results").innerHTML = '<p style="color:red"><b>Error: No regular expression specified</b></p>';
                    return;
                }
                if (!document.form1.str.value) {
                    document.getElementById("results").innerHTML = '<p style="color:red"><b>Error: No content specified</b></p>';
                    return;
                }
                var pattern,
                modifiers …
Run Code Online (Sandbox Code Playgroud)

javascript regex

0
推荐指数
1
解决办法
284
查看次数

删除存储在字符串中的重复行

我有一个包含以下内容的字符串:

This is a line.
This is another line.
This is yet another line.
This is a line.
[...]
Run Code Online (Sandbox Code Playgroud)

如何从字符串中删除重复的行?

c++ string

0
推荐指数
1
解决办法
194
查看次数