I am learning php and html at the moment and I thought I will do some work and create something. I created a page called website.php but only put HTML into the file and ran it on my local web server (MAMP). Everything was working fine until I decide to play with the CSS a bit and change the colours. I changed the colours but it wouldn't appear when I am viewing it in my browser. My questions is, does a pure HTML file not work under the .php extension? While everything works, when I changed its colours, it wouldn't change and I had to change it back to .html before it works. However, I know that you can use HTML in php files without any problems.
Another thing was that the hover selector did not work when I used the .php extension and worked with no problems when I changed it to the .html extension. Can someone explain what is going on?
Wow, that is really odd, are you sure it's not something wrong with the version of MAMP you're using? You should be able to use a .PHP file as you would an HTML file, except of course the PHP file will have PHP code.
Sometimes when you input HTML code on PHP, you can do it like this:
Another way I do it is use the print "<<<EOF" function (like in PERL)
<?php print<<<EOF <a href="http://www.google.com">Test</a> // no need for backslashes. EOF; ?>
Now, I would check the error logs, and see what the exact issue is. I never had any problems with HTML in a PHP file.
Also, sometimes it's easier to place the PHP code at the top of the file, and then add the HTML at the bottom. If you could post the file you are working with than I could probably be of more help.Wow, that is really odd, are you sure it's not something wrong with the version of MAMP you're using? You should be able to use a .PHP file as you would an HTML file, except of course the PHP file will have PHP code.
Sometimes when you input HTML code on PHP, you can do it like this:
[code]<?php
print "
<a href="https://www.google.com/">Link Text</a>
";
>[/code]
This would of course throw an error, the fix is to add backslashes:
[code]<?php
print "
<a href=\"https://www.google.com/\">Link Text</a>
";
>[/code]
Another way I do it is use the print "<<<EOF" function (like in PERL)
[code]<?php
print <<<EOF
<a href="http://www.google.com">Test</a> // no need for backslashes.
EOF;
>[/code]
Now, I would check the error logs, and see what the exact issue is. I never had any problems with HTML in a PHP file.
Also, sometimes it's easier to place the PHP code at the top of the file, and then add the HTML at the bottom. If you could post the file you are working with than I could probably be of more help.
If you post code of your file here, i could help you more to solve your problem. Placing CSS or HTML in .php file shouldn't be a problem. Just depend how you do it.If you post code of your file here, i could help you more to solve your problem. Placing CSS or HTML in .php file shouldn't be a problem. Just depend how you do it.
HTML definitely works inside PHP. But vice versa is not possible. If your file ends with the PHP extension. Then you can easily add the HTML code to your file. And it should run smoothly. I have seen some errors when people tr to use the HTML file for the PHP parsing. And that often results in the failure. So you need to check that out.HTML definitely works inside PHP. But vice versa is not possible. If your file ends with the PHP extension. Then you can easily add the HTML code to your file. And it should run smoothly. I have seen some errors when people tr to use the HTML file for the PHP parsing. And that often results in the failure. So you need to check that out.
Yeah, it's probably a parsing error from what I can see. You should be able to write HTML in a .php file, maybe the IDE is having some errors. Have you managed to fix it?Yeah, it's probably a parsing error from what I can see. You should be able to write HTML in a .php file, maybe the IDE is having some errors. Have you managed to fix it?
Everett
Sometimes when you input HTML code on PHP, you can do it like this:
print "
<a href="https://www.google.com/">Link Text</a>
";
?>
This would of course throw an error, the fix is to add backslashes:
print "
<a href=\"https://www.google.com/\">Link Text</a>
";
?>
Another way I do it is use the print "<<<EOF" function (like in PERL)
print <<<EOF
<a href="http://www.google.com">Test</a> // no need for backslashes.
EOF;
?>
Now, I would check the error logs, and see what the exact issue is. I never had any problems with HTML in a PHP file.
Also, sometimes it's easier to place the PHP code at the top of the file, and then add the HTML at the bottom. If you could post the file you are working with than I could probably be of more help. Wow, that is really odd, are you sure it's not something wrong with the version of MAMP you're using? You should be able to use a .PHP file as you would an HTML file, except of course the PHP file will have PHP code. Sometimes when you input HTML code on PHP, you can do it like this: [code]<?php print " <a href="https://www.google.com/">Link Text</a> "; >[/code] This would of course throw an error, the fix is to add backslashes: [code]<?php print " <a href=\"https://www.google.com/\">Link Text</a> "; >[/code] Another way I do it is use the print "<<<EOF" function (like in PERL) [code]<?php print <<<EOF <a href="http://www.google.com">Test</a> // no need for backslashes. EOF; >[/code] Now, I would check the error logs, and see what the exact issue is. I never had any problems with HTML in a PHP file. Also, sometimes it's easier to place the PHP code at the top of the file, and then add the HTML at the bottom. If you could post the file you are working with than I could probably be of more help.
Are you sure you want to delete this post?