小编Sup*_*vah的帖子

引用div内的div与另一个内的另一个ID相同

当id与嵌套在类似命名的div中的div具有相同的id时,如何通过id引用嵌套div

例如

<div id="obj1">
    <div id="Meta">
        <meta></meta>
    </div>
</div>

<div id="obj2">
    <div id="Meta">
        <meta></meta>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我想获得meta的innerHTML

document.getElementById('obj1').getElementById('Meta').getElementsByTagName('meta')
Run Code Online (Sandbox Code Playgroud)

不起作用

html javascript dom getelementbyid

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

指针作为C中的函数参数

我无法让这个工作.

我在main中启动了变量,我希望将其传递给其他函数并进行更改.我知道可以做到的唯一方法是使用指针或在主函数之外声明变量.我更喜欢使用指针

怎么做?

例如

int main(){
    int variable1 = 5;
    add(&variable1, 6);
    printf("%d", variable1);

    return 0;
}

int add(int *variable1, int addValue){
    variable1 += addValue;

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

我想打印11但我不知道这些指针如何通过其他功能

c variables pointers scope

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

PHP正则表达式将新行限制为最大值为2

我正在使用它,但它正在取代新线的单次出现 <br/><br/>

function nl2br2($string){
    $string = preg_replace('/(\r\n){2,}/', '<br/><br/>', $string);
    //$string = preg_replace('/[\r\n]/', '<br/>', $string);
    return $string;
}
Run Code Online (Sandbox Code Playgroud)

它发生在第一个模式.

php regex unix windows newline

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

如何从PHP中的类返回TRUE | FALSE

我想知道为什么我的php程序在其他地方包含类时没有返回正确的TRUE FALSE值

它就是这样的

source: signup.php

class signup
{
    function buildProfile()
    {
        if($logic){
            $this->success = TRUE;
        }else{
           $this->success = FALSE;
        }
    }
    function __construct()
    {
        $this->success = NULL;
        $this->buildProfile
        return $this->success;
    }
}
Run Code Online (Sandbox Code Playgroud)

我在其他地方

include('signup.php');

$signup = new signup();

if($signup){
    successFunction();
}else....
Run Code Online (Sandbox Code Playgroud)

但它并没有得到$ signup == true,它每次都变得虚假

php conditional return class

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

在C中另一个目录中打开文件

如何实现的?我想用

pFile = fopen( file, "rb" );
Run Code Online (Sandbox Code Playgroud)

其中file是一个char,字符串或long,其中包含包含二进制文件本地路径的文字文本

C:\Documents and Settings\Supernovah\Desktop\Supernovah.bin
Run Code Online (Sandbox Code Playgroud)

但是当然会崩溃。

我也对如何以可移植的方式重现当前目录感兴趣。windows.h有点丑陋,但是如果我不能以便携式的方式做到这一点。随它吧。

谢谢 :)

c binary fopen

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