Jump to content

php vs phtml.


albertlee

Recommended Posts

As far as I am aware they are both simply extensions for php scripts. I've seen people use several different extensions for PHP (especially when they have multiple versions (ie 4 and 5) running simultaneously and need to know which interpreter to use for which extension) such as .php3 .php4 .php .phtml . They are all simply extensions, doesn't really matter, i could call it .bog or .tit and as long as I set it up in the Webserver config to use the php interpreter on files with those extensions it would work exactly the same.

Link to comment
Share on other sites

Not sure exactly what you mean "under the terminal"

 

Iif you mean executing php script via the command line its simply "php filename" and the extension won't matter (you are simply passing a file to the php interpreter, it really doesnt matter what the extension is, extensions really dont mean that much).

 

If you mean you wish to use a php script like any other executable on the shell (ie just run ./script.php) then you can like any other script put "#!/path/to/phpexecutable" which will probably work out as "#!/usr/bin/php" as the very first line of the php file. Then you can do "./phpfile.php" and it will run without having to type "php phpfile.php" on the command line.

 

If you mean you wish to see and change what extensions link up to the php interpreter on the webserver (or the webservers php module) then I'm not exactly sure how you'd do it. I know you can see the AddType declarations that link up the extensions to a particular type which has been associated with the module in the mod_php configuration file -

 

# vim: ft=apache sw=4 ts=4

<IfDefine PHP4>

 

# Load the module first

<IfModule !sapi_apache2.c>

LoadModule php4_module extramodules/libphp4.so

</IfModule>

 

# Set it to handle the files

<IfModule mod_mime.c>

AddType application/x-httpd-php .php

AddType application/x-httpd-php .phtml

AddType application/x-httpd-php .php3

AddType application/x-httpd-php .php4

AddType application/x-httpd-php-source .phps

</IfModule>

 

# Fix some bugs

<Files *.php>

# keep this the same size as post_max_size in php.ini

# LimitRequestBody 8388608

</Files>

<Files *.php3>

# keep this the same size as post_max_size in php.ini

# LimitRequestBody 8388608

</Files>

<Files *.php4>

# keep this the same size as post_max_size in php.ini

# LimitRequestBody 8388608

</Files>

<Files *.phps>

# keep this the same size as post_max_size in php.ini

# LimitRequestBody 8388608

</Files>

<Files *.phtml>

# keep this the same size as post_max_size in php.ini

# LimitRequestBody 8388608

</Files>

 

</IfDefine>

 

You MAY be able to add more extensions using the AddType directive on a per directory basis using the .htaccess file but I'm not sure (would imagine it would be a main config only kind of option, try it).

 

You can also use various scripts via CGI scripts and can simply place them in the cgi-bin and these can use a variety of interpreters (by simply using the interpreter address at the top of the script as I mentioned).

Link to comment
Share on other sites

to get "php filename" to work you need more than the standard php software installed.

 

(offten called php-cli or php4-cli)

 

Good point, forgot about that, heh, is always compiled into mine as one of the default options so I never really think about it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.