SEOClerks

Does html not work in a php file?



Write the reason you're deleting this FAQ

Does html not work in a php file?

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?

Thanks.

Comments

Please login or sign up to leave a comment

Join
Everett
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:


<?php
print "
<a href="
https://www.google.com/">Link Text</a>
";
?>


This would of course throw an error, the fix is to add backslashes:

<?php
print "
<a href=\"https://www.google.com/\">Link Text</a>
"
;
?>



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.



Are you sure you want to delete this post?

anwebservices
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.



Are you sure you want to delete this post?

MendasDigital
Yes, you can place HTML, CSS, Javascript, etc in a PHP file. You don't have to put any PHP code in the file at all.

Perhaps the page was cached. If so, when you changed the color and re-visited the page, you were still viewing the old version of the content. When you changed the file extension from .php to .html, you were viewing a different page, so you got the new content, instead of the cached version. That's my guess anyway. Try clearing your browser cache between each visit, and see if that helps.



Are you sure you want to delete this post?

Everett
I forgot about page caching, and this normally isn't available unless you turn such a feature on via your host, or if you were to actually programmatically cache the page yourself. Now, as for HTML not appearing on the page, even when the code seems to be working fine is beyond me. I would assume it's a settings error, or an error with the php application itself. Never had I ever had a problem displaying HTML/CSS/JS/etc on a PHP file.. very odd indeed.



Are you sure you want to delete this post?

overcast
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.



Are you sure you want to delete this post?

Fuzyon
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?



Are you sure you want to delete this post?

Order Now
Process Time: 0.079490900039673

Possible Duplicate queries found!
MatchCountSQLScript
SELECT * FROM `questions` as q JOIN categories_faq as c ON q.catid=c.CATID WHERE (q.status=1 OR (q.status=2 AND userid='') ) AND q.quesid='20586'1SELECT q.*, c.seo as CatSEO, c.name as CatName, c.parentid FROM `questions` as q JOIN categories_faq as c ON q.catid=c.CATID WHERE (q.status=1 OR (q.status=2 AND userid='') ) AND q.quesid='20586'

/opt/clerks-staging/docroot/viewfaq.php 496 () ()

SELECT * FROM seoclerks.members WHERE USERID='311920'1SELECT * FROM seoclerks.members WHERE USERID='311920'

/opt/clerks-staging/docroot/include/functions/includes/member.php 445 GetAllUserDetails() ()

SELECT * FROM seoclerks.members WHERE USERID=3119201SELECT googleplus_profile FROM seoclerks.members WHERE USERID=311920

/opt/clerks-staging/docroot/include/functions/main.php 16914 GetGooglePlusProfileFromId() ()

SELECT * FROM ratings_faq as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=20586 LIMIT 51SELECT m.username FROM ratings_faq as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=20586 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM answers a, seoclerks.members b WHERE a.quesid='20586' AND a.userid=b.USERID and b.status='1' AND a.status=1 ORDER BY a.combined_votes DESC, a.date_answered asc1SELECT a.answer, a.USERID, a.upvotes, a.downvotes, a.ansid, a.parentid, a.combined_votes, a.date_answered, b.username, b.userlevel, b.profilepicture FROM answers a, seoclerks.members b WHERE a.quesid='20586' AND a.userid=b.USERID and b.status='1' AND a.status=1 ORDER BY a.combined_votes DESC, a.date_answered asc

/opt/clerks-staging/docroot/viewfaq.php 1245 () ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112067 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112067 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112101 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112101 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112085 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112085 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112153 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=112153 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=117700 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=117700 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=122546 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=122546 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

UPDATE questions SET total_views = total_views + 1 WHERE quesid='20586'1UPDATE questions SET total_views = total_views + 1 WHERE quesid='20586'

/opt/clerks-staging/docroot/include/functions/main.php 1765 update_Faqviewcount() ()

SELECT * FROM questions WHERE quesid!='20586' AND status='1' AND (question like '%Does html work php file?%' OR question like '%Does%' OR question like '%html%' OR question like '%work%' OR question like '%file?%') -- ORDER BY RAND() LIMIT 151SELECT quesid, question, seo, userid FROM questions WHERE quesid!='20586' AND status='1' AND (question like '%Does html work php file?%' OR question like '%Does%' OR question like '%html%' OR question like '%work%' OR question like '%file?%') -- ORDER BY RAND() LIMIT 15

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() ()

SELECT * FROM seoclerks.members WHERE USERID='147' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='147' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='9' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='9' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='1508' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='1508' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='318' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='318' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM members_ledger WHERE script='/opt/clerks-staging/docroot/viewfaq.php' AND querystring LIKE '%id=20586%' AND added>=UNIX_TIMESTAMP(NOW())-1200 GROUP BY USERID 1SELECT USERID, username FROM members_ledger WHERE script='/opt/clerks-staging/docroot/viewfaq.php' AND querystring LIKE '%id=20586%' AND added>=UNIX_TIMESTAMP(NOW())-1200 GROUP BY USERID

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() ()

SELECT * FROM categories1SELECT * FROM categories

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() parseRedundantQueriesCache()

select * from categories_software order by name asc1select * from categories_software order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_GetSoftwareCategories()

select * from categories_wanttobuy order by name asc1select * from categories_wanttobuy order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_wantcategories()

select * from categories_wanttotrade order by name asc1select * from categories_wanttotrade order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_tradecategories()

SELECT * FROM seoclerks.members WHERE USERID='2951.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='2951.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='254580.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='254580.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='486532.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='486532.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='589438.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='589438.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='600422.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='600422.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

select * from categories_faq order by name asc1select * from categories_faq order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_GetFaqCategories()

Invalid SQL

count(*)sql1error_msg

Expensive SQL

Tuning the following SQL could reduce the server load substantially
LoadCountSQLMaxMin

Suspicious SQL

The following SQL have high average execution times
Avg TimeCountSQLMaxMin