小编Nic*_*lis的帖子

PHP __get __set方法

class Dog {

    protected $bark = 'woof!';

    public function __get($key) {
        if (isset($this->$key)) {
            return $this->$key;
        }
    }
    public function __set($key, $val) {
        if (isset($this->$key)) {
             $this->$key = $val;
        }
    }
 }
Run Code Online (Sandbox Code Playgroud)

使用这些功能有什么意义.

如果我可以使用

$dog = new Dog();
$dog->bark = 'woofy';
echo $dog->bark;
Run Code Online (Sandbox Code Playgroud)

为什么我要把'吠声'称为"吠叫" protected?在这种情况下,这些__get()__set()方法是否有效地使'吠声'公开?

php getter setter magic-methods

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

为什么sprintf在这里返回false?

我想弄清楚为什么sprintf在这里返回false.谁能摆脱任何光明?

sprintf( "select dog_name, date_format(meet_date, '%D %M %Y') as date, track_name, race_name, race_stakes, race_class, race_stakes, result_place, result_box, winner_name, winner_id, result_dog_trainer, race_distance
                                from dog
                                join result using( dog_id )
                                join race r using( race_id )
                                join meet using( meet_id )
                                join track using( track_id ) 
                                join (select dog_name as winner_name, dog_id as winner_id, race_id 
                                        from dog
                                        join result using( dog_id )
                                        where result_place = 1                                    
                                        ) t0 on t0.race_id = r.race_id
                                where dog_id = %d
                                    order by meet_date desc
                                limit %d", …
Run Code Online (Sandbox Code Playgroud)

php printf string-parsing

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

在MySQL中的多个列上有所不同

我希望找出MySQL数据库中不同行的计数.

id | val1 | val2 | val3

1  |  1   |  1   |  1
2  |  1   |  1   |  1
3  |  2   |  2   |  2
4  |  2   |  2   |  2
Run Code Online (Sandbox Code Playgroud)

在上面的表上,查询将返回

val1 | val2 | val3 | count
1    |   1  |  1   |   2 
2    |   2  |  2   |   2
Run Code Online (Sandbox Code Playgroud)

有没有人知道在MySQL中实现这一目标的合理有效方法.

mysql sql count distinct

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

Adobe Illustrator - 尝试适应画板命令时脚本崩溃

activeDocument.fitArtboardToSelectedArt()
Run Code Online (Sandbox Code Playgroud)

调用此命令时,AI 在 AI 5.1/6 32bit 和 64bit 版本上崩溃。我可以使用菜单中的命令。有没有人遇到过这个?有谁知道解决方法?

完整的代码。

    function exportFileToJPEG (dest) {
    if ( app.documents.length > 0 ) {

        activeDocument.selectObjectsOnActiveArtboard()
        activeDocument.fitArtboardToSelectedArt()//crashes here
        activeDocument.rearrangeArtboards()

        var exportOptions = new ExportOptionsJPEG();
        var type = ExportType.JPEG;
        var fileSpec = new File(dest);
        exportOptions.antiAliasing = true;
        exportOptions.qualitySetting = 70;
        app.activeDocument.exportFile( fileSpec, type, exportOptions );
    }
}
var file_name = 'some eps file.eps'
var eps_file = File(file_name)


var fileRef = eps_file;



if (fileRef != null) {
    var optRef = new OpenOptions();
    optRef.updateLegacyText = true;
    var …
Run Code Online (Sandbox Code Playgroud)

extendscript adobe-illustrator

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

为.创建正则表达式

我正在尝试创建一个正则表达式来接受

整数

123

要么

然后是一个整数,然后是另一个整数

123_45

这就是我所拥有的

/^[0-9]+_*[0-9]*$/
Run Code Online (Sandbox Code Playgroud)

我如何使_*[0-9]*(第二部分)可选

php regex

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