>
Quote:
On 18 Nov, 13:04, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
Quote:
>Service4PC schreef:
>>
>>
>>
Quote:
>>Hi all,
>>I've a problem... I'm writing an extension for php, and i need to
>>execute a file php... but only the content of the file and not the
>>file...
>>Now I better explain:
>> - the extension get the file content of a php file (php code and html
>>code mixed..)
>> - execute the content with some zend api function
>>I've already tried with zend_eval_string but not good because not
>>execute the html code/open php tag.
>>The same for zend_execute_script :(
>>If someone has used the zend api, i need your help
>>PS: sorry for my english, it is difficult to explain my goals :(
>Hi,
>>
>Maybe I understand wrong, but if you need the raw PHP file, simply use
>the fylesystem functions to do so, and NO URL wrapper.
>>
>for example:
>GOOD:
>// This will get the content of your PHP file
>$Path = "/home/service42/public_html/myPHPfile.php";
>$PHPContent = file_get_contents ($Path);
>>
>BAD:
>// This will give you the result of the 'executed' file
>$URL = "http://www.example.com/~service42/myPHPfile.php";
>$PHPContent = file_get_contents ($URL);
>>
>Regards,
>Erwin Moller
>>
>Read more here:
http://nl3.php.net/manual/en/ref.filesystem.php
>>
Service4PC schreef:
Quote:
An example maybe clarify the ideas...
>
file php:
<?php
myfunction('<pre><?php echo "hello world"; ?></pre>'); // this cannot
be execute with a simply eval :(
?>
>
file extension.c
[...]
PHP_FUNCTION(myfunction)
{
char *code;
int code_len;
>
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &code,
&code_len) == FAILURE) {
RETURN_NULL();
}
>
// how i can execute the source code of variable code????
// ...
}
[...]
>
i hope this help to explain my idea...
Hi,
[Please don't toppost, fixed]
I am still a bit at a loss.
You php file was this:
<?php
myfunction('<pre><?php echo "hello world"; ?></pre>');
?>
What do you expect from that file?
I mean: You can get its content via normal filesystemfunctions as I
described in my earlier post.
What really is strange is of course the content itsef:
myfunction('<pre><?php echo "hello world"; ?></pre>');
That is NOT executed PHP code: The "hello world" is not echo'ed at all.
It is just the literal string '<pre><?php echo "hello world"; ?></pre>'
being passed to some function.
I don't know how your application is set up or supposed to do, but this
looks like strange design to at first sight.
I might be missing something though...
Are you maybe writing some parser that will produce PHP sourcefiles itself?
(Then it would make sense.)
So sorry, it is still not clear to me. :-/
Regards,
Erwin Moller
--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare