PHP/Javascript Eval Primer Tutorial

PPHP/Javascript Eval Primer Tutorial

PHP/Javascript Eval Primer Tutorial

Today’s tutorial adds an onion layer on top of an answer of a question on Yahoo Answers. This is the way I really like to program. Get the essence right first, then build onion layers on top, and have supervisors of supervisors of supervisors … for Onion a then Onion 1-a then Onion A-1-a … then Onion of the Eval Dimension … what! … yes, good old much maligned (because, yes, it needs to be used with caution for software security reasons), Eval! What is Eval? Starting to sound familiar with all the election talk? Eval is the construction of a line of code and the language calculating the answer on the fly, and both PHP and Javascript have their own “Eval”s, pretty obviously achieving completely different things (being as PHP is serverside and the Javascript am using is clientside), but both happening to be useful for the achievement of this tutorial, where we take a file with calculator type statements in it, like “56 * 23 / 234=” and constructing a program to answer the calculator type question. Well, did this in PHP/Javascript and then realized, as I slipped on a non-existant onion peel, that this method could be extended for a CSV input scenario. So the end result is a webpage that accepts via the URL with an ?infile= clause, the input data in either style of format, and the extra “get” parameter &interactive=y to say you want a Javascript alert box for each calculator result, rather than seeing all the results at once (also available are &leaveinquote=y and &justanswer=y (or n) and the &leavequote=y&justanswer=y would allow a comma-separated series of strings be concatenated and output to the screen if you choose the default Mathematical operators of (all) + signs).

Here is a link to some downloadable PHP programming source code which can be renamed to eval_js_php.php for your perusal.

Enjoy the live interactive tutorial (or one we baked before here, or one that was half-baked here or maybe you’d like some “sweet, green icing flowing down”), as we depart with Wikipedia’s view of Eval.

In some programming languages, eval is a function which evaluates a string as though it were an expression and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; in languages that support syntactic abstractions (like Lisp), eval’s input will consist of abstract syntactic forms.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Software, Tutorials and tagged , , , , , , , . Bookmark the permalink.

7 Responses to PHP/Javascript Eval Primer Tutorial

  1. Nairobi says:

    Oh my goodness! a fantastic short article dude. Thanks Nevertheless We’re experiencing concern with ur rss . Usually do not know why Struggle to sign up for it. Can there be anyone acquiring identical rss dilemma? Everyone who knows kindly respond. Thnkx

  2. produce says:

    I like what you guys are up also. Such clever work and reporting! Keep up the superb works guys I‘¦ve incorporated you guys to my blogroll. I think it’ll improve the value of my web site :)

  3. There is definately a lot to know about this topic. I really like all of the points you made.|

  4. homepage says:

    Thank you, I have just been searching for information about this subject for a while and yours is the best I’ve discovered till now. But, what about the conclusion? Are you positive about the source?

  5. Vital says:

    I was studying some of your content on this site and I believe this site is rattling instructive! Keep on posting.

  6. favorite says:

    Hello my friend! I want to say that this article is amazing, great written and come with almost all significant infos. I‘¦d like to see more posts like this .

  7. Appreciating the time and energy you put into your website and detailed information you offer. It’s great to come across a blog every once in a while that isn’t the same outdated rehashed information. Fantastic read! I’ve saved your site and I’m including your RSS feeds to my Google account.|

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>