M. of CA
M. of CA

Reputation: 1546

PHP How do i execute other file extensions into PHP?

Iam trying to find the setting, where i can have PHP execute other file extensions into the PHP Engine?

Any idea?

Upvotes: 2

Views: 2680

Answers (3)

Adam Fowler
Adam Fowler

Reputation: 1751

You can execute other files using the include function. This will parse any file with the php tags into php!

**NOTE - Including files from the webroot that are non-php means that people can gain access to the script in question, without it being executed. I highly Recommend that you don't do this in most situations.

Upvotes: -1

matzahboy
matzahboy

Reputation: 3024

This would have to do with how your server handles requests. The server if probably configured to pass requests with the .php extension to php. You could modify your server configuration to pass other requests to the php parser as well.

Since I don't know what type of server you're using, I can't say how to modify the config.

Upvotes: 2

Matt Stein
Matt Stein

Reputation: 3053

exec() will execute an external program, if that's what you mean. You can capture the output, but I'm not sure if that's what you mean by "into the PHP engine."

http://php.net/manual/en/function.exec.php

Edit: If you mean running other file extensions as PHP, you can edit .htaccess to specify the file type. For example, to run .html as PHP:

AddType application/x-httpd-php .html

Upvotes: 5

Related Questions