Search code examples
phpconvertersrtf

PHP - Syntax of exec() function to call another php file


This question is in reference to:

Free (preferably) PHP RTF to HTML converter?

I'm trying to execute that last line of code in my php:

exec(rtf2htm file.rtf file.html)

I understand what parameters need to go within the parentheses, I just do not know how to write it. I've looked at multiple examples along with the php documentation and still I remain confused, so could someone show me how it is written? rtf2htm refers to a PHP file which converts RTF to HTML.

Ultimately what I am trying to do is convert the content of numerous RTF docs to HTML, maintaining the formatting, while not creating tags such as<head> or <body> which programs like Word or TextEdit generate when converting to HTML.


Solution

  • rtf2htm is not a php script, it is a program installed on the server. exec() is used to call external applications.

    EDIT: After looking up this script, it seems that it is indeed a php script. But it has been coded to be usable from the command line only.

    This should work:

    <?php
    
    exec('php /path/to/rtf2htm /path/to/source.rtf /path/to/output.html');
    
    ?>