小编Val*_*our的帖子

在SQLite中使用乱码搜索数据库

我想知道是否可以使用给定的加扰字在数据库中搜索.

mobs在数据库中有一个表,它包含怪物名称的名称

如果给怪物的名字是A Golden DregonA Golden DfigonA Gelden Dragon我希望它发现A Golden Dragon或与接近它从数据库匹配.通常,最大的一个或两个字母像这样被加扰.

只有SQL查询才有可能吗?或者我应该通过解析给定的怪物名称来构建查询?

我在代码方面使用LUA.

sqlite search

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

在类之外声明一个新的静态变量

有没有办法在该类之外声明新的静态变量,即使它没有在类中设置?

// Using this class as a static object.
Class someclass {
    // There is no definition for static variables.
}

// This can be initialized
Class classA {
    public function __construct() {
        // Some codes goes here
    }
}

/* Declaration */
// Notice that there is no static declaration for $classA in someclass
$class = 'classA'
someclass::$$class = new $class();
Run Code Online (Sandbox Code Playgroud)

如何做呢?

谢谢您的建议。

php declaration static-variables

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

使用正则表达式从HTML文档中的链接中提取URL

我需要捕获给定html中的所有链接.

这是示例代码:

<div class="infobar">
    ... some code goes here ...
    <a href="/link/some-text">link 1</a>
    <a href="/link/another-text">link 2</a>
    <a href="/link/blabla">link 3</a>
    <a href="/link/whassup">link 4</a>
    ... some code goes here ...
</div>
Run Code Online (Sandbox Code Playgroud)

我需要把所有环节中div.infobar,与开始/link/

我试过这个:

preg_match_all('#<div class="infobar">.*?(href="/link/(.*?)") .*?</div>#is', $raw, $x);
Run Code Online (Sandbox Code Playgroud)

但它给了我唯一的第一场比赛.

谢谢你的建议.

php regex preg-match-all

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

PHP分配另一个类的$ this

我一直想知道是否有可能将另一个对象分配给$ this?

在CodeIgniter中,我从主控制器调用另一个控制器.

应用/控制器/ module.php

Class Module extends CI_Controller {
    public function __construct() {
        parent::__construct();
    }

    public function _remap($class, $args = array()) {
        // doing some checks that is there a valid file, class and method
        // assigning the $method.
        // including MY_Module class. I'am extending every module from this class.
        // then:
        $EG = new $class();
        call_user_func_array(array(&$EG, $method), array_slice($this->uri->rsegments, 3));
    }
}
Run Code Online (Sandbox Code Playgroud)

在被叫班级:

Class Users extends MY_Module
{
    public function __construct() {
        parent::__construct();
    }

    public function index() {
        // …
Run Code Online (Sandbox Code Playgroud)

php controller codeigniter class this-pointer

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