小编use*_*729的帖子

有没有可靠的方法来了解请求是否在PHP中的Ajax上下文中?

我需要以不同的方式处理这两种情况,有一个很好的解决方案吗?

php ajax

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

如何使__set也适用于PHP中的静态操作?

当我打电话self::$parameter = 1;__set不叫.

有办法解决吗?

php static magic-methods

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

如何在PHP中调用的函数中获取调用文件的绝对路径?

file.php:

call()...
Run Code Online (Sandbox Code Playgroud)

如何获得file.php内部的绝对路径call()

注意call()可能在另一个文件中定义.

another.php:

function call(){..}
Run Code Online (Sandbox Code Playgroud)

file.php:

include(path_to_another.php);
call();
Run Code Online (Sandbox Code Playgroud)

php path

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

debug_backtrace()对于生产环境中的严重使用是否安全?

它的功能非常强大,我担心它的稳定性和性能.

你怎么看?

UPDATE

我正在做的是这样的:

    $old_dir = getcwd();
    chdir( dirname($included_file) );
    include ( $included_file );
    chdir( $old_dir );
Run Code Online (Sandbox Code Playgroud)

基本上它只是这样include ( $included_file );,但在内部$included_file它找不到3.php与它本身位于同一目录中,所以我手动设置cwd并且它工作.但是如果我找到它无法找到的原因会很好至于为什么debug_backtrace需要,因为3.php它被另一个包含func,因为相对路径不起作用,它必须debug_backtrace用来获取包含文件路径,最后使用如下所述的绝对路径.

重现并不容易,因为上面的代码是在一个方法的上下文中,而且还有更多......如果没有其他人遇到过这种问题我想停在这里,无论如何,成本只是额外的3线,没什么大不了的.

php debug-backtrace

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

java这样的OOP语言如何封装辅助函数(常用的api)?

这些功能可能很难适应特定的类,

处理它们的最佳做法是什么?

java oop

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

什么时候.h不需要包含头文件?

这有效:

#include <iostream>
using namespace std;
Run Code Online (Sandbox Code Playgroud)

但这失败了:

#include <stdio>
Run Code Online (Sandbox Code Playgroud)

什么时候.h不需要?

关于命名空间问题,我没有找到这样的逻辑cstdio:

#pragma once
#ifndef _CSTDIO_
#define _CSTDIO_
#include <yvals.h>

#ifdef _STD_USING
 #undef _STD_USING
  #include <stdio.h>
 #define _STD_USING

#else /* _STD_USING */
 #include <stdio.h>
#endif /* _STD_USING */

// undef common macro overrides
 #undef clearerr
 #undef feof
 #undef ferror
 #undef getc
 #undef getchar
 #undef putc
 #undef putchar

 #define _HAS_CONVENTIONAL_CLIB 1
 #define _IOBASE    _base
 #define _IOPTR _ptr
 #define _IOCNT _cnt

#ifndef _FPOSOFF
  #define _FPOSOFF(fp)  ((long)(fp))
#endif /* _FPOSOFF …
Run Code Online (Sandbox Code Playgroud)

c++ include

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

为什么它不会违反分段?

据说下面的代码会导致分段违规:

#include <stdio.h> 
#include <string.h> 

void function(char *str) {
   char buffer[16];

   strcpy(buffer,str);
}

int main() {
  char large_string[256];
  int i;

  for( i = 0; i < 255; i++)
    large_string[i] = 'A';

  function(large_string);
  return 1;
}
Run Code Online (Sandbox Code Playgroud)

它的编译和运行方式如下:

gcc -Wall -Wextra hw.cpp && a.exe
Run Code Online (Sandbox Code Playgroud)

但没有任何结果.

注意

上面的代码确实会覆盖ret地址等等,如果你真的明白它下面会发生什么.

RET地址将0x41414141要具体.

重要 这需要深刻的堆栈知识

c memory stack segmentation-fault

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

如何使用MATLAB检索任意图像的背景颜色?

这又是从弹簧联接另一个问题这一个,

如何以编程方式获取图像的背景颜色?

例:

替代文字

对于上面的图像,背景颜色是白色.

matlab image-processing

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


哪些目录包含C/C++中的语句搜索?

test.c:

#include "file.h"
Run Code Online (Sandbox Code Playgroud)

在上面的语句中,将搜索哪些目录?

我想要test.c搜索locates 的目录,对吗?

但这就是全部吗?

顺便说一下,使用头文件有什么好处?Java不需要头文件......

c c++ include

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