phphtmlphar

Calling a function contained in a phar from an html page


I'm not sure if this is possible.

I have a phar file that I can access via web browser and it displays the page defined within the phar. On the page is a button

<form action="phar://codeSniffer.phar/web/interface.php" method="post" enctype="multipart/form-data">

As you can see I am attempting to call a function defined within the phar and it is not getting called.

Is this possible at all?


Solution

  • A browser cannot call functions of server-side languages. It can make an HTTP request to a web server; it doesn't have any clue what that web server does, what languages it interprets or whether that language has any concept of a "function". It just sends a plaintext HTTP request and receives a plaintext HTTP response. Secondarily, phar:// isn't a protocol known to browsers, and even if it was, the browser couldn't run the PHP file at the end of it because it doesn't understand PHP.

    No, you need a web server that can run PHP and link to that, not link to a PHP file via phar://.