eval

mysql/php - store html templates within the a database

I am wondering the best way to store html templates in a database where I am able to retrieve them and insert variables. Obviously I could store them as php and then 'EVAL' the record.... but I heard it was evil. is there a better way? :) edit: Sorry I wasn't clear... I tried to simplify it by saying html templates... what I really m...

mysql - store embed codes (youtube, vimeo etc)

How best to store the html for embedding? the only ways I can think of are: take the embed html and add <?php echo $var1; ?> where the id's go then store it in the db and use Eval to execute it. or insert a strange combination of characters to act as a marker to be replaced in php by the id's. ...

Is Using eval In Python A Bad Practice?

I am using the following class to easily store data of my songs. class Song: """The class to store the details of each song""" attsToStore=('Name', 'Artist', 'Album', 'Genre', 'Location') def __init__(self): for att in self.attsToStore: exec 'self.%s=None'%(att.lower()) in locals() def setDetail(self,...

Javascript eval results in "undefined function" but works in Firebug

I'm wondering why when I call: eval("myFunc(1,2,3)") in the Firebug console on a rendered page, the function executes properly, but when I call the same eval within by javascript within then page, I get a " is not defined" error that pops up in the Firebug console. Part of my problem is that I don't have control over the incoming HTML/...

Eval script for server side control's ID property?

Using the following Eval script for setting ID property causes error. Error message: the server tag is not well formed. <asp:Panel runat="server" ID="<%# Eval("RENTER_ID") %>" Visible="false"> Even replacing "" with '' of ID property generates error. While using '', its error message "The ID property of a control can only be set usi...

PHP: How to return an instantiated class object, given a class name?

They say that eval() is evil. I want to avoid the use of the eval() line using proper PHP5 functionality. Given a class name in a static class method, how do I make it return a real object? class Model { public static function loadModel($sModelPath) { if (!(strpos(' ' . $sModelPath, '/')>0)) { $sModelPath .= '/' . $sModelPat...

javascript eval

eval('({"suc":true})') The above is wrong,should be: eval('{"suc":true}') Why? ...

JSON eval problem

I have an ASP.net website running on two different machines, one with a Vista OS and the other with Windows Server 2003. I am using jQuery to make an AJAX call to a web method in the code-behind, that then calls a web service. On both machines, the call to the web method and web serivce executes without problem and properly formatted J...

How to disable eval function without going to php.ini file?

Hello All, Is there a way to disable eval function without doing so from php.ini file. I have tried ini_set function but even that doesn't work. Basically I want my framework users to decide whether this function should be enabled or not through a config file. If they say no, i should be able to disable it using code as i can't go to s...

How do you know to use Container.DataItem when data binding in ASP.NET? Is there a reference?

Is there a reference for data binding? I've seen a bunch of different ways to data bind things, but I've never found a reference. Is there one? I know there are Bind and Eval, but when does Container.DataItem come into play? Are there other "hidden" objects and methods available? Or is Container.DataItem the object that is being use...

Calling a function by a string in JavaScript and staying in scope

Hi, I've been playing around and searching a bit, but I can't figure this out. I have a pseudo private function within a JavaScript object that needs to get called via eval (because the name of the function is built dynamically). However, the function is hidden from the global scope by a closure and I cannot figure out how to reference i...

Compile a string to Ruby bytecode for better performance -- like compile() in Python

I have a string (authenticated, trusted, etc.) containing source code intended to run within a Ruby loop, quickly. In Python, I would compile the string into an abstract syntax tree and eval() or exec() it later: # Python 3 example given_code = 'n % 2 == 1' pred = compile(given_code, '<given>', 'eval') print("Passed:", [n for n in rang...

When is `eval` in Ruby justified

Another question inspired this one: Mostly everybody agrees that eval is bad, and in most cases there is more elegant / safer replacement. So I wanted to ask: if eval is misused that often, is it really needed as a language feature? Is it doing more evil than good? Personally, the only place I find it useful is to interpolate strings ...

trying to find a file/line for: .(eval):289: warning: don't put space before argument parentheses

So, I get this warning when I'm running my tests in ruby/RoR .(eval):289: warning: don't put space before argument parentheses I've checked every where (but obvoiusly not) and I can't find the origin of this error. The above error just pops up inbetween the unit tests ... Can someone clue me in onto how to find the location of this e...

Substitute for eval() for using LiveValidation constructor

Hi. I'm using LiveValidation for input elements. These come in a table retrieved with an AJAX call, and can be multiples of 4, anywhere between 4 and 36. I'm using eval to call the constructor for LiveValidation as the number of input elements can vary after each AJAX call and I couldn't think of another way (I don't have much experien...

How can I dynamically include Perl modules without using eval?

Hi, I need to dynamically include a Perl module, but if possible would like to stay away from eval due to work coding standards. This works: $module = "My::module"; eval("use $module;"); But I need a way to do it without eval if possible. All google searches lead to the eval method, but none in any other way. Is it possible to do it...

IE8 Json problem

I'm facing very strange issue, I'm getting JSON object from django powered site and excuting it using eval(). It works on all the other browsers except all versions of IE. in IE, I am getting "variable_name" is null or not an object. I've tried everything I could but so far no luck. here is my json object var results = {"result":[ { ...

Why does EcmaScript 5 strict mode go to such great lengths to restrict the identifier `eval`

According to the spec (Annex C), strict-mode code can't do pretty much anything that might assign any identifier with the name eval. I can understand that one might want to restrict use of the actual eval function, but I don't see what purpose is served by restricting use of the name? ...

dynamically create a class without a namespace

I am trying to dynamically create a class using the eval method. It is working fine except for one small problem. As my code shows I am creating the Browser class inside the BrowserFactory class. When I do this the Browser class has an added namespace of BrowserFactory. Is there anyway to evaluate the Browser class from a string with...

why my "eval" function doesn't work ,i think it can be print 'b',but not

a='''b="ddd"''' eval(repr(a)) print str(a) print b Please try to use the code, rather than text, because my English is not very good, thank you ...