albertlee Posted August 25, 2005 Posted August 25, 2005 Sorry, I am not familar with php, but does any one give a shortcut distinction between these two??? because I am designing a server side communication program....
Aeternus Posted August 25, 2005 Posted August 25, 2005 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.
albertlee Posted August 25, 2005 Author Posted August 25, 2005 thanks... last question, how do know what extension is used for php under the terminal???
Aeternus Posted August 25, 2005 Posted August 25, 2005 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).
Klaynos Posted August 25, 2005 Posted August 25, 2005 to get "php filename" to work you need more than the standard php software installed. (offten called php-cli or php4-cli)
Aeternus Posted August 25, 2005 Posted August 25, 2005 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.
albertlee Posted August 25, 2005 Author Posted August 25, 2005 alright, thanks for the introductory exp.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now