Calling PHP Code Snippets within PHP Application 
Author Message
 Calling PHP Code Snippets within PHP Application

This is very likely a newbie question, but I'd still appreciate a
pointer. I need to call PHP Code snippets (saved in a mySQL-database
etc) within my main PHP Application. I would like to do the
following things:

- Code Snippet should not have access to or knowledge of Main
Application variables and methods - ie. each code snippet has its own
private scope
- main application exposes a number of specific methods and variables
("environment") to the snippet that it can use
- a way for the code snippet to return some variables (ie. a success
bool) - possibly using (re-importing back from the snippet) the
variables exposed by the main application

In which direction should I look?

Thanks a lot,
Marc Floessel



Sat, 01 Oct 2005 19:26:52 GMT  
 Calling PHP Code Snippets within PHP Application

Quote:

> This is very likely a newbie question, but I'd still appreciate a
> pointer. I need to call PHP Code snippets (saved in a mySQL-database
> etc) within my main PHP Application. I would like to do the
> following things:

> - Code Snippet should not have access to or knowledge of Main
> Application variables and methods - ie. each code snippet has its own
> private scope
> - main application exposes a number of specific methods and variables
> ("environment") to the snippet that it can use
> - a way for the code snippet to return some variables (ie. a success
> bool) - possibly using (re-importing back from the snippet) the
> variables exposed by the main application

eval($snippet); is what you want.

To protect your main application from the snippets simply wrap the eval
in a function.

function eval_snippet($snippet) {
        $envvar = $GLOBALS['envvar'];
        eval($snippet);
        $GLOBALS['returnvar'] = $returnvar;

Quote:
}

YOou will still have to check that the snippet doesn't refer to
$GLOBALS, $_POST, $_GET, $_REQUEST, $_ENV, $_SERVER


Sat, 01 Oct 2005 19:57:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling Python Code Snippets within Python Application

2. cannot call php site out of php site

3. php mysql sample code php shareware like KB knowledgebase

4. Calling a compiled function from within PHP?

5. php newsgroup [ alt.php ]

6. install PHP 4.2 and PHP 4.3 on the same host

7. different PHP-Version with differengt php.ini files?

8. Apache + PHP not processing php

9. Newbie to PHP - Displaying local PHP Files

10. FLEX / BISON generator for PHP (JavaCC for PHP!)

11. Help: PHP works with .php but not .html

12. PHP+MySQL vs. PHP+PostgreSQL

 

 
Powered by phpBB® Forum Software