html to php
Moderator: General Moderators
-
asif_phpdn
- Forum Commoner
- Posts: 28
- Joined: Sun Aug 26, 2007 8:50 pm
html to php
Can I convert any html file to php?
Convert Html to PHP?
??
Code: Select all
$html = file_get_contents('htmlfile.html');
///
$html = '<div>This is Html</div>';
///
?>
<div>This is Html</div>
<?php
///
Yes. Just change the extension from .html to .php 
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Just put
Code: Select all
<?php
echo 'content of file'
//or
print ''
?>-
asif_phpdn
- Forum Commoner
- Posts: 28
- Joined: Sun Aug 26, 2007 8:50 pm
Then just put the html code in echo and that brings php from html???Rovas wrote:Just putCode: Select all
<?php echo 'content of file' //or print '' ?>
You also have the option to set up the server to execute the HTML pages like PHP pages.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
It is far better and useful to change it to .phps... It needs this directive in Apache config file:scottayy wrote:Yes. Just change the extension from .html to .php
Code: Select all
AddType application/x-httpd-php-source .phpsThere are 10 types of people in this world, those who understand binary and those who don't
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
NEVER DO THIS ON PRODUCTION SERVERS. THIS IS A SECURITY RISK AND A BAD RECOMMENDATION.VladSun wrote:It is far better and useful to change it to .phps... It needs this directive in Apache config file:Code: Select all
AddType application/x-httpd-php-source .phps
Exposing the PHP code behind your pages is a bad move. This directive should never be set in production environments.
Ooops, my mistake - I read the topic as "Convert PHP to HTML", i.e. show PHP code as HTMLEverah wrote:NEVER DO THIS ON PRODUCTION SERVERS. THIS IS A SECURITY RISK AND A BAD RECOMMENDATION.VladSun wrote:It is far better and useful to change it to .phps... It needs this directive in Apache config file:Code: Select all
AddType application/x-httpd-php-source .phps
Exposing the PHP code behind your pages is a bad move. This directive should never be set in production environments.
But ... one should never say "never"
What about having a PHP example on a production server
There are 10 types of people in this world, those who understand binary and those who don't
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
highlight_file(), without making changes to your server settings.
@Everah
I can't agree with you.
Suppose, I have *.phps files on a server. With or without this directive the source will be exposed - do you agree? So, using this directive doesn't involve any security risks.
It's the same case as with *.inc.php files - the shouldn't be named *.inc, but nobody says "DON'T USE EVIL INCLUDE() FUNCTION!"
Your post is a little bit of FUD
I can't agree with you.
Suppose, I have *.phps files on a server. With or without this directive the source will be exposed - do you agree? So, using this directive doesn't involve any security risks.
It's the same case as with *.inc.php files - the shouldn't be named *.inc, but nobody says "DON'T USE EVIL INCLUDE() FUNCTION!"
Your post is a little bit of FUD
There are 10 types of people in this world, those who understand binary and those who don't
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Not sure I understand what you are asking here. If the server does not know what to do with a .phps file extension, it will show a .phps file as plain text. However, you do not put .phps files on the server, you put .php files on the server, so the server, not knowing what to do with a .phps file looks for it, cannot find it, and returns a 404.VladSun wrote:Suppose, I have *.phps files on a server. With or without this directive the source will be exposed - do you agree? So, using this directive doesn't involve any security risks.
I agree that naming a php file .inc is stupid. For that, you could name it .txt and have the same protection. I am not sure what this has to do with the include function though.VladSun wrote:It's the same case as with *.inc.php files - the shouldn't be named *.inc, but nobody says "DON'T USE EVIL INCLUDE() FUNCTION!"
If you want people to be able to see the source of your application code, by all means go ahead and turn that feature on for your servers. But offering the advice to people here to open up their code on their servers is irresponsible. It is a security risk. Everything that is in a PHP file becomes exposed if the .phps directive is turned on.
They can't see it if it is *.php file... They would be able to see it if it is *.phps file (thats the analogy with *.inc and *.inc.php). So where is the security issue?
One need to rename a .php file to .phps file to make this directive applied. That's why having this directive turned on is not a security issue.
One need to rename a .php file to .phps file to make this directive applied. That's why having this directive turned on is not a security issue.
There are 10 types of people in this world, those who understand binary and those who don't