相关疑难解决方法(0)

什么时候是PHP的eval邪恶?

在我用PHP开发的这些年里,我总是听说使用eval()是邪恶的.

考虑以下代码,使用第二个(更优雅)选项是否有意义?如果没有,为什么?

// $type is the result of an SQL statement
// e.g. SHOW COLUMNS FROM a_table LIKE 'a_column';
// hence you can be pretty sure about the consistency
// of your string
$type = "enum('a','b','c')";

// possibility one
$type_1 = preg_replace('#^enum\s*\(\s*\'|\'\s*\)\s*$#', '', $type);
$result = preg_split('#\'\s*,\s*\'#', $type_1);

// possibility two
eval('$result = '.preg_replace('#^enum#','array', $type).';');
Run Code Online (Sandbox Code Playgroud)

php eval

82
推荐指数
9
解决办法
4万
查看次数

PHP的create_function()与仅使用eval()

在PHP中,您有create_function()函数,它创建一个唯一的命名lambda函数,如下所示:

$myFunction = create_function('$foo', 'return $foo;');
$myFunction('bar'); //Returns bar
Run Code Online (Sandbox Code Playgroud)

这实际上是否更好(除了更容易)然后只是做:

do{
 $myFunction = 'createdFunction_'.rand();
}
while(function_exists($myFunction));
eval("function $myFunction(\$foo) { return \$foo; }");
$myFunction('bar'); //Returns bar
Run Code Online (Sandbox Code Playgroud)

create_function真的更好吗?(除了事实上它更容易)

php eval create-function

4
推荐指数
2
解决办法
5630
查看次数

ionCube如何在内部工作?

ionCube以加密格式存储php文件,它作为php扩展安装,但我想知道的是当我从非加密的php文件请求加密的php文件时,php编译器如何执行它.

它是否将加密文件发送到ionCube服务器并获取原始文件并编译该文件或其他内容.

表示我们的服务器和ionCube之间的通信方式.我想这是通过卷曲但我想知道它是如何工作的.

php encryption ioncube

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

标签 统计

php ×3

eval ×2

create-function ×1

encryption ×1

ioncube ×1