Can I convert the php file to htm?

Source: Internet
Author: User
Can I convert the php file to htm? How can I create a php file with parameters and obtain the final htm file displayed in the background?


Reply to discussion (solution)

Save the result output by the php program to a file

Save the result output by the php program to a file



What should I do in the background? Could you elaborate? thank you.

For example, a php

    
              <?php echo $title;?>        


It also contains other PHP files, $ title set in other files, and other include files

What should I do if I want to get the htm file of my browser?

Ob_start ('HTML ');
Function html ($ s ){
File_put_contents (basename ($ _ SERVER ['php _ SELF ']). '.htm', $ s );
}
//......

Use the template engine

What does LZ mean by "display?
If the client shows the code in html format, php simply uses echo.
If the url seen by the client is an html extension, you can use pseudo-static or directly specify to use php to parse *. html in apache.

What does LZ mean by "display?
If the client shows the code in html format, php simply uses echo.
If the url seen by the client is an html extension, you can use pseudo-static or directly specify to use php to parse *. html in apache.



For example, I now have a. php? P1 = a & p2 = B. I want to generate an htm file that displays the content of the preceding php file with parameters.

I just want to get an htm with the same browser effect as php and hope to give some advice.

The moderator has already said
Check the three functions ob_start ob_get_contents file_put_contents.

Echo file_get_contents ('http: // www.domain.com/index.php? Action = xxx'); // directly obtain the generated html

Call a. php? When p1 = a & p2 = B, the htm file is generated, and then the page can be accessed directly using htm-> see #4
Call a. php? P1 = a & p2 = B directly display the page of The htm file and directly echo

Do you want to use pseudo static?

Rewrite ^ (. *)/index _ (\ d +) _ (\ d1_0000.html $1/index. php? Val1 = $2 & val2 = $3 & val3 = $4 last;

This mainly refers to/index. php? Val1 = 121 & val2 = 222 & val3 = 232 convert to/index_121_222_232.html format

You can use IE (Chrome) to open a php Site. if you don't want to see html, you can't.

RewriteEngine on
AddType application/x-httpd-php. html. htm

Use
. Htaccess: Use the preceding statement to change all php files to static suffixes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.