小编Nik*_*huk的帖子

获得"间接修改超载财产无效"的通知

我想使用Registry来存储一些对象.这是一个简单的Registry类实现.

<?php
  final class Registry
  {
    private $_registry;
    private static $_instance;

    private function __construct()
    {
      $this->_registry = array();
    }

    public function __get($key)
    {
      return
        (isset($this->_registry[$key]) == true) ?
        $this->_registry[$key] :
        null;
    }

    public function __set($key, $value)
    {
      $this->_registry[$key] = $value;
    }

    public function __isset($key)
    {
      return isset($this->_registry[$key]);
    }

    public static function getInstance()
    {
      if (self::$_instance == null) self::$_instance = new self();
      return self::$_instance;
    }
}

?>
Run Code Online (Sandbox Code Playgroud)

当我尝试访问这个类时,我得到"间接修改重载属性没有效果"的通知.

Registry::getInstance()->foo   = array(1, 2, 3);   // Works
Registry::getInstance()->foo[] = 4;                // Does not …
Run Code Online (Sandbox Code Playgroud)

php

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

如何从Colorbox本身加载的内容中设置Colorbox标题?

让我解释.我使用Colorbox加载HTML文件并将其显示在iframe中.HTML文件包含<title>标记.是否可以使用该<title>标签作为Colorbox弹出窗口的标题?我可以使用onComplete事件,但是怎么样?

编辑:我应该澄清代码:

父HTML:

<!doctype html>
<html>
    <head>
        <title>This is parent</title>
        <script src="jquery.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $('a.cb').colorbox({
                    iframe : true,
                    title  : function() { /* here goes the code */ },
                });
            });
        </script>
    </head>
    <body>
        <a class="cb" href="popup.html">Popup</a>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

儿童HTML:

<!doctype html>
<html>
    <head>
        <title>The title</title>
    </head>
<body>
    ...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

基本上我想要Colorbox显示子HTML代码的标题.

jquery title colorbox

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

无法测试Bash中是否存在文件

请考虑以下Bash脚本:

function dosomething {
    local fname="~/.bash_profile"
    if [[ -f "$fname" ]]; then
        echo "proceeding"
    else
        echo "skipping"
    fi
}

dosomething
Run Code Online (Sandbox Code Playgroud)

虽然我知道〜/ .bash_profile存在,但我总是"跳过".为什么?

bash tilde-expansion

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

标签 统计

bash ×1

colorbox ×1

jquery ×1

php ×1

tilde-expansion ×1

title ×1