PositronicSpleen Posted December 16, 2009 Share Posted December 16, 2009 I'm sort of new at PHP, but I've been having a really simple, really strange problem. Whenever I try to print HTML tags through PHP, the greater-than symbol (>) always terminates the script early. The problem isn't exactly the same on IE as Firefox, but they're both problematic. Furthermore, I've tried this on XP, Vista, and Windows 7, on separate machines. All signs point to me having done something wrong, but I honestly can't figure out what's going on; I even tried using example code, but that doesn't work either! I took a screenshot of the script and how it renders in two browsers, it's the attachment. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/ Share on other sites More sharing options...
oni-kun Posted December 16, 2009 Share Posted December 16, 2009 Try writing this script in NOTEPAD, and run it again: <?php echo '<h1>HTML tags hate me</h1>'; ?> <h1>HTML tags hate me</h1> I'm not sure if your code editor converts the < to < or otherwise but it shouldn't perform as so. EDIT: PHP is serverside, it shouldn't matter which browser it's on. Firefox usually hides PHP tags. It might be the problem I thought. In IE+FF, What does the source code say when you view it? Is part of the PHP code there? Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/#findComment-978229 Share on other sites More sharing options...
mikesta707 Posted December 16, 2009 Share Posted December 16, 2009 Do you have a php server? like apache? You can't just run PHP in a browser like javascript/html. Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/#findComment-978231 Share on other sites More sharing options...
oni-kun Posted December 16, 2009 Share Posted December 16, 2009 Do you have a php server? like apache? You can't just run PHP in a browser like javascript/html. You're right! I did not notice him running it off a folder, especially .html. OP, download something such as WAMP to run PHP code. Once installed you can access your pages from http://127.0.0.1/index.php provided your php files are in C:\easywamp\www\index.php or similar. A good thing about WAMP is it includes Apache linked to PHP/SQL so you do not need to endlessly configure it to run on your machine. This is a simple way to test PHP files which are compatible when you upload them online. Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/#findComment-978233 Share on other sites More sharing options...
PositronicSpleen Posted December 16, 2009 Author Share Posted December 16, 2009 I was running it from a server before, I just changed machines and thought this would be faster. The result on a live server is exactly the same, as evidenced by another attached screenshot. Actually, you can see the URL now, I guess it's no big deal. Does anyone else get the same result? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/#findComment-978238 Share on other sites More sharing options...
oni-kun Posted December 16, 2009 Share Posted December 16, 2009 I was running it from a server before, I just changed machines and thought this would be faster. The result on a live server is exactly the same, as evidenced by another attached screenshot. Actually, you can see the URL now, I guess it's no big deal. Does anyone else get the same result? You're entering the PHP code into a .html document, therefor the server will NOT parse it as PHP and give you that erroneous code. You will need to add the following to your .htaccess file to run PHP code within html: AddHandler application/x-httpd-php .php .html Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/#findComment-978245 Share on other sites More sharing options...
PositronicSpleen Posted December 16, 2009 Author Share Posted December 16, 2009 Well, that solves that mystery! I was told that xhtml files could run fine under the php extension, I guess I mistakenly assumed it also worked the other way around, too. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/185307-weird-premature-script-termination/#findComment-978258 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.