Minimeallolla Posted February 16, 2011 Share Posted February 16, 2011 It's been a while since I've done any coding and now I'm getting back into it. Just to double check, javascript within a .php file would be fitted after the head tag , but before the body tag? Quote Link to comment Share on other sites More sharing options...
haku Posted February 16, 2011 Share Posted February 16, 2011 the PHP is irrevelant. All that matters is where the javascript ends up in the HTML output. Script tags can be anywhere inside the head or body tags. They cannot be outside of these tags (such as between the head and body like you were asking). Quote Link to comment Share on other sites More sharing options...
moa Posted February 16, 2011 Share Posted February 16, 2011 hi there, PHP is great scripting language ! it does not restrict you for using other languages such as Javascript or any other. Well the solution can be done depending on the type of coding you are doing in the php (i mean you are dong embedding the php into the HTML or just using the whole php file) if you are using embedded style then there is no problem! you can use javascript as usual way you use in normal HTML page ! But you are using full php page and you are embedding HTML into the PHP tags then you should write script into the 'echo' or similar output sentences. BEST OF LUCK ! Quote Link to comment Share on other sites More sharing options...
Minimeallolla Posted February 16, 2011 Author Share Posted February 16, 2011 I've realised I worded that very badly. What I should have said was, in a html file, where should the [<? php include ("javascript_file.php")] go? I'm including a php file that is full of javascript to make the code more presentable, into a html file. I put it within the <head> tag Quote Link to comment Share on other sites More sharing options...
haku Posted February 16, 2011 Share Posted February 16, 2011 As I mentioned before, what's relevant is where it's outputted in the (X)HTML output. As long as it is between the head tags or the body tags, it will be valid. Quote Link to comment Share on other sites More sharing options...
moa Posted February 17, 2011 Share Posted February 17, 2011 Then, in that case it doesn't mind where you put that include file. Its only depend upon your style and convenience. I would certainly like to include my all include files into the <head> section of the file. Quote Link to comment Share on other sites More sharing options...
Minimeallolla Posted February 17, 2011 Author Share Posted February 17, 2011 @moa, sometimes that could interferre with head or meta tags? Certain bits of php/java belong in certain areas of head and body tags? Quote Link to comment Share on other sites More sharing options...
moa Posted February 17, 2011 Share Posted February 17, 2011 @Minimeallolla The Php script will never interferes with the <head> or <meta> section of the file, taking that you have embedded it correctly. If you found it interfering the sections then its mainly due to improper embedding of PHP About your second concern I am really not sure what you trying to say ! PHP and JAVA have their different stands ! If you explains me what you meant to say i will definatly be helpful. As I have coded in both PHP and Java Quote Link to comment Share on other sites More sharing options...
Minimeallolla Posted February 17, 2011 Author Share Posted February 17, 2011 That is what I was trying to say. I havn't coded php for a while now but from memory if a meta tag is outside of the head tag it wont redirect and cause an error, or something along those lines. Don't worry, I don't really need help in with php just yet (: Quote Link to comment Share on other sites More sharing options...
haku Posted February 18, 2011 Share Posted February 18, 2011 You are correct Minemola - if the php script you are including echos or prints data to the page, you need to include it in the section where you want that output to be. Quote Link to comment Share on other sites More sharing options...
dany Posted February 23, 2011 Share Posted February 23, 2011 Nice this certinly helped me too...!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.