jamesjmann Posted February 5, 2011 Share Posted February 5, 2011 When I put this above all else in my document and test it offline, all I see is code in the browser. But when I test it on my web server, I can view the markup and whatnot. Does anyone know why this is? Quote Link to comment https://forums.phpfreaks.com/topic/226757--/ Share on other sites More sharing options...
steveangelis Posted February 5, 2011 Share Posted February 5, 2011 What do you mean view offline? Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170166 Share on other sites More sharing options...
jamesjmann Posted February 5, 2011 Author Share Posted February 5, 2011 What do you mean view offline? Offline as in not on my web host's server, on my laptop connected to the internet without a server, mysql, or php Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170168 Share on other sites More sharing options...
fortnox007 Posted February 5, 2011 Share Posted February 5, 2011 i would first of all recommend you use <?php as starting tag instead of <? And concerning your question, if you open up a php file locally without having a server with php installed you will ofcourse see all the code. install xampp for instance and run it again. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170176 Share on other sites More sharing options...
jamesjmann Posted February 5, 2011 Author Share Posted February 5, 2011 i would first of all recommend you use <?php as starting tag instead of <? And concerning your question, if you open up a php file locally without having a server with php installed you will ofcourse see all the code. install xampp for instance and run it again. I have quite a few php documents that open up just fine off a web server (i.e., i can view the markup on them). It's just when I add that little bit of code at the very top of the php document, the markup no longer becomes visible. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170299 Share on other sites More sharing options...
fortnox007 Posted February 5, 2011 Share Posted February 5, 2011 i would first of all recommend you use <?php as starting tag instead of <? And concerning your question, if you open up a php file locally without having a server with php installed you will ofcourse see all the code. install xampp for instance and run it again. I have quite a few php documents that open up just fine off a web server (i.e., i can view the markup on them). It's just when I add that little bit of code at the very top of the php document, the markup no longer becomes visible. Well do as you like and use shorttags if you think that is the way to go i don't mind. About opening stuff in your browser locally without a server running( because that is what ou said you did). see my answer again. Post your code. including the stuff you include. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170301 Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 Use full <?php open tags. Short <? open tags are now disabled by default. See what happens when you do that. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170305 Share on other sites More sharing options...
crmamx Posted February 5, 2011 Share Posted February 5, 2011 Sounds like you are doing exactly what I did when I wrote my first php program a couple of weeks ago. Since a .html program would execute and display in the browser, I figured a .php program would do the same thing. Doesn't exactly work that way if you don't have all the "goodies" installed on your PC. I changed my file associations to open .php with wordpad because notepad screws up the format. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170414 Share on other sites More sharing options...
jamesjmann Posted February 5, 2011 Author Share Posted February 5, 2011 Use full <?php open tags. Short <? open tags are now disabled by default. See what happens when you do that. It works on my web server with both forms of php tags. It's just when I test it off the server without xamp, wamp, apache, etc. it comes up as code. i tried changing the "<?" to "<?php" but that didn't do anything. I'm forced to conclude that the only way to resolve this issue, is either eliminate the code from the document altogether, or just resort to testing my css/html through my web server only. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170458 Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 Well, of course. You can't expect that code such as PHP, that must be parsed by an interpreter on a webserver will function without the use of a webserver. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170463 Share on other sites More sharing options...
jamesjmann Posted February 6, 2011 Author Share Posted February 6, 2011 Well, of course. You can't expect that code such as PHP, that must be parsed by an interpreter on a webserver will function without the use of a webserver. Yes, that makes sense, HOWEVER, all of my other php scripts within the <html></html> tags do NOT affect my html or css online or off. Is it because the php script is outside the <html></html> tags? Or is it just that particular function that causes this? Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170506 Share on other sites More sharing options...
trq Posted February 6, 2011 Share Posted February 6, 2011 Your not making allot of sense. PHP needs to be interpreted by it's parser which is an extension to a web server. Hence php needs a web server to work. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170518 Share on other sites More sharing options...
jamesjmann Posted February 6, 2011 Author Share Posted February 6, 2011 Your not making allot of sense. PHP needs to be interpreted by it's parser which is an extension to a web server. Hence php needs a web server to work. I know that. All php codes inside the <html></html> in my documents don't work, but don't affect the css/html when viewed in a browser offline. If you put php code outside of the <html></html> offline, the php code doesn't work, but it also affects my markup and css and I can't test my html offline before uploading it. Does that make sense? lol. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170524 Share on other sites More sharing options...
trq Posted February 6, 2011 Share Posted February 6, 2011 PHP does not care about being inside or outside of <html></html> tags. As for the rest, no, it doesn't make allot of sense. Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170549 Share on other sites More sharing options...
jamesjmann Posted February 6, 2011 Author Share Posted February 6, 2011 PHP does not care about being inside or outside of <html></html> tags. As for the rest, no, it doesn't make allot of sense. Lol, I'm sorry. Sometimes php confuses me. But anyway, I think I know why it's doing that. I just download a script that is similar to my document(s) and it does the same thing so I'm guessing that that's just the way it is. Thanks all for your replies! Quote Link to comment https://forums.phpfreaks.com/topic/226757--/#findComment-1170554 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.