小编y2k*_*y2k的帖子

如何在Zend Framework的控制器插件中获取引导资源

protected function _initDatabase()
{
     $params = array(
            'host'     => '',
            'username' => '',
            'password' => '',
            'dbname'   => '',
        );

    $database = Zend_Db::factory('PDO_MYSQL', $params);
    $database->getConnection();
    return $database;
}
Run Code Online (Sandbox Code Playgroud)

.

class App_Controller_Plugin_Test extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Http $request)
    {
        // how i get database?

    }
}
Run Code Online (Sandbox Code Playgroud)

php zend-framework

19
推荐指数
3
解决办法
2万
查看次数

在Qt中解析HTML的最佳方法?

我如何在Qt中解析充满BAD html的页面上的所有"a"html标签"href"属性?

html c++ qt

17
推荐指数
2
解决办法
2万
查看次数

在C#中帮助\ 0终止字符串

我正在使用低级本机API,我发送一个不安全的字节缓冲区指针来获取一个c-string值.

所以它给了我

// using byte[255] c_str
string s = new string(Encoding.ASCII.GetChars(c_str));

// now s == "heresastring\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0(etc)";
Run Code Online (Sandbox Code Playgroud)

所以显然我做得不对,我怎么摆脱多余的?

c# string cstring

15
推荐指数
4
解决办法
3万
查看次数

如何在字符串c#中的某个索引后获取所有内容

让我们说我有字符串:

"MyNamespace.SubNameSpace.MyClassName"

如何在最后一段时间后提取所有内容,"MyClassName"

.net c# string

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

封装是否荒谬?

对于我的软件开发编程类,我们应该为RSS feed创建一个"Feed Manager"类型的程序.以下是我处理FeedItems实现的方法.

好又简单:

struct FeedItem {
    string title;
    string description;
    string url;
}
Run Code Online (Sandbox Code Playgroud)

我得到了标记,"正确"的示例答案如下:

class FeedItem
{
public:
    FeedItem(string title, string description, string url);

    inline string getTitle() const { return this->title; }
    inline string getDescription() const { return this->description; }
    inline string getURL() const { return this->url; }

    inline void setTitle(string title) { this->title = title; }
    inline void setDescription(string description){ this->description = description; }
    inline void setURL(string url) { this->url = url; }

private:
    string title;
    string description; …
Run Code Online (Sandbox Code Playgroud)

c# c++ encapsulation yagni

11
推荐指数
4
解决办法
1351
查看次数

为什么在C#getter/setter中使用私有变量?

我一直都看到这个:

    private int _myint;

    public int MyInt
    {
        get
        {
            return _myint;
        }
        set
        {
            _myint = value;
        }
    }
Run Code Online (Sandbox Code Playgroud)

对我而言,这似乎与:

    public int MyInt{ get; set; }
Run Code Online (Sandbox Code Playgroud)

那么为什么每个人都做前者...为什么私人VAR?

c#

8
推荐指数
4
解决办法
8534
查看次数

用C#指示生成int数组?

以下C++程序按预期编译和运行:

#include <stdio.h>

int main(int argc, char* argv[])
{
    int* test = new int[10];

    for (int i = 0; i < 10; i++)
            test[i] = i * 10;

    printf("%d \n", test[5]); // 50
    printf("%d \n", 5[test]); // 50

    return getchar();
}
Run Code Online (Sandbox Code Playgroud)

我能为这个问题做出的最接近的C#简单示例是:

using System;

class Program
{
    unsafe static int Main(string[] args)
    {
        // error CS0029: Cannot implicitly convert type 'int[]' to 'int*'
        int* test = new int[10];

        for (int i = 0; i < 10; i++)
            test[i] = i …
Run Code Online (Sandbox Code Playgroud)

c c# c++ pointers

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

在Python中解析人的名字和姓氏

非常感谢所有帮助过的人!

所以基本上我需要解析一个名字并找到以下信息:

名字

First Initial(如果员工的首字母缩写为DJ,则使用两个首字母)

姓氏(包括员工是否有后缀,如Jr.或III.)


所以这是我正在使用的界面:

输入:

names = ["D.J. Richies III", "John Doe", "A.J. Hardie Jr."]
for name in names:
   print parse_name(name)
Run Code Online (Sandbox Code Playgroud)

预期产出:

{'FirstName': 'D.J.', 'FirstInitial': 'D.J.', 'LastName': 'Richies III' }
{'FirstName': 'John', 'FirstInitial': 'J.', 'LastName': 'Doe' }
{'FirstName': 'A.J.', 'FirstInitial': 'A.J.', 'LastName': 'Hardie Jr.' }
Run Code Online (Sandbox Code Playgroud)

不是很擅长正则表达式,实际上这可能有点过头了.我只是在猜测:

if name[1] == ".":  # we have a name like D.J.?
Run Code Online (Sandbox Code Playgroud)

呃,我不知道,很久没有使用Python了.

任何帮助将不胜感激!谢谢 :)

非常感谢所有帮助过的人,你救了我的命!

python parsing

7
推荐指数
2
解决办法
2万
查看次数

为什么WinAPI对BOOL类型使用int(32位)?

// <windef.h>

typedef int                 BOOL;
Run Code Online (Sandbox Code Playgroud)

这不是浪费内存,因为int是32位吗?

以防万一,我错了,我试图发送一个正常bool*到所需的功能BOOL*,并没有工作,直到我用的typedef INT.

c++ windows int winapi boolean

6
推荐指数
2
解决办法
2900
查看次数

为什么++重载但不是 - 对于c ++ bool

我试图找出为什么我可以++b一个bool而不是--b

#include <stdio.h>

int main(void)
{
    bool b = false;
    ++b;
    --b; // error C2428: '--' : not allowed on operand of type 'bool'

    printf("%s %d", b ? "true" : "false", b);

    getchar();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c c++ boolean operator-overloading

6
推荐指数
0
解决办法
172
查看次数