source code: eval()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
erinus
Forum Newbie
Posts: 5
Joined: Fri Apr 10, 2009 11:34 am

source code: eval()

Post by erinus »

Hi,
I wanna add some c code into eval(string) let it can check string's syntax.
But I don't know which file(*.c) has the source code of eval().
Please give me some guidance or direction.
Thanks!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: source code: eval()

Post by Benjamin »

You can use php_check_syntax() for this:

http://us3.php.net/manual/en/function.p ... syntax.php
erinus
Forum Newbie
Posts: 5
Joined: Fri Apr 10, 2009 11:34 am

Re: source code: eval()

Post by erinus »

Thank you, astions.

I wanna do another work in eval(), like certificate, etc..
I know PHP has openssl_private_encrypt, php_check_syntax(), ... functions.
But I must modify the source code of eval().
So, can you tell me which file I need modify?
Thank you for you.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: source code: eval()

Post by Benjamin »

I'm not sure what file it is in, but I have downloaded the source and it is quite organized. It's most likely in a file called eval.c or close to that at least.
erinus
Forum Newbie
Posts: 5
Joined: Fri Apr 10, 2009 11:34 am

Re: source code: eval()

Post by erinus »

There is no file name like "*eval*".

PHP is a interprete lanaguage, I think eval will be extractd from *.php by php syntax analyzer.
So, I use UltraEdit to find "eval" in all *.c.
But the result is large as mountain. I can't identify which section is used for eval().
erinus
Forum Newbie
Posts: 5
Joined: Fri Apr 10, 2009 11:34 am

Re: source code: eval()

Post by erinus »

I find the eval in source files (php-5.2.9.tar.gz).
I filtered the result and list:
========================================================================
ext/pcre/php_pcre.c (line 854):
static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
int *offsets, int count, char **result TSRMLS_DC)
{
......
}


main/main.c (line 598):
switch (EG(current_execute_data)->opline->op2.u.constant.value.lval)
{
case ZEND_EVAL:
function = "eval";
is_function = 1;
break;
......
}


Zend/zend_builtin_functions.c (line 1828):
switch (Z_LVAL(ptr->opline->op2.u.constant))
{
case ZEND_EVAL:
function_name = "eval";
build_filename_arg = 0;
break;
......
}


Zend/zend_vm_def.c (line 2896):
case ZEND_EVAL:
{
char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
efree(eval_desc);
}
break;


Zend/zend_vm_execute.c (line 2060):
case ZEND_EVAL:
{
char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
efree(eval_desc);
}
break;
========================================================================

And, are these files right?
erinus
Forum Newbie
Posts: 5
Joined: Fri Apr 10, 2009 11:34 am

Re: source code: eval()

Post by erinus »

Well...

I found it.

ext/pcre/php_pcre.c

before line 921.

Thanks everybody.
Post Reply