http://www.w3schools.com/php/func_misc_eval.asp
...only to find this horror:
"Tip: This function can be useful for storing PHP code in a database."
After I picked myself up off the floor, I thought of this evil
recommendation:
eval($_GET["code"]);
Just a little Saturday morning humor.
Sincerely,
-=- Craig A. Lance
I think the fact that HPHP does not support eval() (yet) just say that
its implementation is not complete for general usage at the moment.
When the source is ready for release, I hope that some real experts in
PHP core team will take a close look at it.
Regards,
Dinh
It's impossible to figure out what code is in the eval statement at
compile time. Therefore, it can never be compiled.
- M.
anyway ...
i think the problem with eval, create_function etc. regarding to
hiphop is, that eval and create_function are used to dynamically
create php code -- how should such be translated to c++?
eval() will never be supported by the hiphop compiler; only by the interpreter.
It's impossible to figure out what code is in the eval statement at
compile time. Therefore, it can never be compiled.
- M.
They had mentioned that the V8 engine had some very good ideas they
could use, hopefully this is one of them. JIT can make an application
faster over time by caching the results of such compiles (Java does
this).
However I feel that eval() is mostly a really big hack, it's rare the
good developer that actually needs to use it and it brings more
problems than solutions (security concerns and scope comes to mind).
On Feb 6, 5:25 pm, Zachary Carter <zack.car...@gmail.com> wrote:
On 6 Feb., 18:34, Craig Lance <craigala...@gmail.com> wrote:
> Well, for example: one could have a field in a database that specifies an
> upload folder for images as:
>
> $_SERVER['DOCUMENT_ROOT'] . '/images/'
>
> ...which on my development server evaluates to:
>
> C:/xampp_1.7.1/xampp/htdocs/images/
>
> I mean you can really get creative. But, this help HipHop, one must think
> in a more static way of making a C++ compiler happy.
>
> -=- Craig
>
> On Sat, Feb 6, 2010 at 11:25 AM, Zachary Carter <zack.car...@gmail.com>wrote:
create_function('with literal string') is actually supported. That happens
when people want simple and anonymous functions on the fly for some array
walking functions. We just can't support create_function($variable) yet.
preg_replace/e can be re-written into a different way. I'll explain later
when we have the code in front of you.
-Haiping
Honestly I don't see why go through the trouble of supporting both of
these if they simply bring bad code to the table 98% of the time.
Create_function is useful but I believe lambda functions will probably
replace it entirely once you guys get to PHP v5.3.
I'd really like if you guys could 'tone down' some of the silly things
the PHP core team did (probably due to outside pressure, namespaces
and their operator ring a big bell).
The result would be a 'stricter' language with better code ... but
that's another discussion. You're aiming for the established huge-
coded giants that probably don't feel like rewriting their stuff just
so HPHP works.
Besides, once we're at the point where we know the compiler does most
operations correctly we can start trying new things (like eval and
variable functions and etc).
As of right now, I doubt the compiler is 100% stable and that's why
they left out these 'harder' features.
In this case you can get around this by including a class file
dynamically. As far I know, dynamic includes are supported by HipHop.
I'm not saying that eval is completely worthless, it DOES have its
uses. But they are very few (the example you mentioned is one I
guess), they're usually not vital to the application and can probably
be re-done without the use of eval. The function is used incorrectly
so much and is so slow that it feels like it's more trouble than it's
worth.
class a {
}
if (!class_exists('a')) {
class a {
}
}
?>
works perfectly for me ... i of course don't know, what hiphop would
make out of this ...
harald
On 6 Feb., 23:26, Павел Митрофанов <pavel.mitrofa.nov...@gmail.com>
wrote:
What A.J. was saying is that if someone tries to call an non-existing
class, you can create it on the fly with eval() and base it off of
some parent. It will still be a class / object and hopefully, nothing
will break (thus avoiding the fatal error of class not defined).