eval

PHP eval issue with PHP + HTML code

♀尐吖头ヾ 提交于 2019-11-28 09:34:45
问题 I've got PHP and HTML code stored in a database table. When I get this data, I need to echo the HTML and process the PHP. I thought I could use eval() for this, which works, if I do this eval("echo 'dlsj'; ?> EVALED "); I get "dlsjEVALED" printed out. The problem is, I get a fatal error when I run longer scripts. Things like: Parse error: syntax error, unexpected '<' in /home/content.php(18) : eval()'d code on line 1 回答1: I would guess that you're trying to eval() something that contains an

Foreach loop unable to find object

匆匆过客 提交于 2019-11-28 09:18:13
问题 I am trying to use foreach with the parallel backend to speed up computation (of cross validation of an {AUCRF} random forest for feature selection, if this does matter). In the process of doing so i need to get a subset of a vector. The name of the vector can change but is accessible as character vector. I used the eval(parse()) construct(good idea?) to get a subset of the vector. Example: library(parallel) library(foreach) library(stats) #create cluster clu <- makeCluster(detectCores() - 1)

Node.js Global eval, throwing ReferenceError

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 08:46:11
I am trying to learn JavaScript from the Rhino book. I was trying to execute the following code from the book with regards to eval() . I am using node.js (v0.10.29) to execute the examples. var geval = eval; // aliasing eval to geval var x = 'global'; // two global variables var y = 'global'; function f () { var x = 'local'; // define a local variable eval('x += "changed";'); // direct eval sets the local variable return x; } function g () { var y = 'local'; // define a local variable geval('y += "changed";'); // indirect eval sets global variable return y; } console.log(f(), x); // =>

in c#: expression evaluation function like flash script

▼魔方 西西 提交于 2019-11-28 08:21:27
问题 Duplicate of: How can I evaluate a C# expression dynamically? See also: C# eval equivalent? How to evaluate expression. Maybe like: int a=1; int b=3; int c=Eval("a+b"); or int c=int.parse("1+3*(2+3)"); This seems stupid to me. is it possible in c#? 回答1: You can take code, and using the CSharpCodeProvider write an Eval function that actually compiles your code into an in-memory assembly and then executes that code. See this CodeProject article for sample source. 回答2: Not directly. C# contains

What is the best way to handle exceptions in Perl?

懵懂的女人 提交于 2019-11-28 08:08:23
I've noticed that Exception.pm and Error.pm don't seem to be extensively used in the Perl community. Is that due to the large footprint of eval for exception handling? Also Perl programs appear to have a much more lenient policy regarding exception handling in general. Is there a compelling reason for this? In any event what would be the best method for exception handling in Perl? Michael Carman The consensus of the Perl community seems to be that Try::Tiny is the preferred way of doing exception handling. The "lenient policy" you refer to is probably due to a combination of: Perl not being a

Why does eval() exist?

安稳与你 提交于 2019-11-28 08:03:39
Many programmers say it is a bad practice to use the eval() function: When is JavaScript's eval() not evil? I'd like to take a moment to address the premise of your question - that eval() is "evil"... Is this eval() dangerous? Buggy evaled code can violate security properties just as easily as buggy source code... Why not eval() JSON? There are a number of ways that your security may be compromised... Is there ever a good reason to use eval()? Yes - when there is no other way to accomplish the given task with a reasonable level of clarity... This eliminates 99% of cases where eval is used...

python eval 用法

吃可爱长大的小学妹 提交于 2019-11-28 07:48:40
python eval 用法 eval   功能:将字符串str当成有效的表达式来求值并返回计算结果。   语法: eval(source[, globals[, locals]]) -> value   参数:     source:一个Python表达式或函数compile()返回的代码对象     globals:可选。 变量作用域,全局命名空间,如果被提供,则必须是一个字典对象。     locals:可选。 变量作用域,局部命名空间,如果被提供,可以是任何映射对象。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 可以把 list , tuple , dict 和string相互转化。 ################################################# 字符串转换成列表 a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]" type (a) # <type 'str'> b = eval (a) print (b) # [[1, 2], [3, 4], [5, 6], [7, 8], [9, 0]] type (b) # <type 'list'> ######################

Exploiting JavaScript's eval() method

旧城冷巷雨未停 提交于 2019-11-28 07:47:27
Many developers believe that JavaScript's eval() method should be avoided. This idea makes sense from a design perspective. It is often used as an ugly workaround when a simpler, better option is available. However, I do not understand the concerns about security vulnerabilities. Certainly, running eval() gives the hacker the ability to run any JavaScript code that you can run. But can't they do this anyway? In Chrome, at least, the Developer Tools allow the end-user to run their own JavaScript. How is eval() more dangerous than the Developer Tools? As B-Con mentioned, the attacker is not the

Perl: Why doesn't eval '/(…)/' set $1?

一曲冷凌霜 提交于 2019-11-28 07:09:35
问题 If a regular expression match occurs inside an eval, changes to the capture-related variables ($1, etc.) are not visible in the outside environment. Is this a bug? perlop and perlre don't seem to mention any such restriction. For example: use strict; use warnings; $_ = "hello"; eval '/(.*)/'; print "GOT: $1\n"; gives: Use of uninitialized value $1 in concatenation (.) or string at -e line 1. GOT: A more succinct demo is: perl -we '$_="foo"; eval q(/(.*)/;) ; print "GOT:$1\n";' 回答1:

Are Dynamic Prepared Statements Bad? (with php + mysqli)

江枫思渺然 提交于 2019-11-28 07:04:29
I like the flexibility of Dynamic SQL and I like the security + improved performance of Prepared Statements. So what I really want is Dynamic Prepared Statements, which is troublesome to make because bind_param and bind_result accept "fixed" number of arguments. So I made use of an eval() statement to get around this problem. But I get the feeling this is a bad idea. Here's example code of what I mean // array of WHERE conditions $param = array('customer_id'=>1, 'qty'=>'2'); $stmt = $mysqli->stmt_init(); $types = ''; $bindParam = array(); $where = ''; $count = 0; // build the dynamic sql and