octacube Posted January 27, 2009 Share Posted January 27, 2009 I have this strange problem i've been trying to find an answer googling around for a whole workday now without any luck. All the code runs fine until the first html tag (no matter which tag) and after that just vomits all the source code without processing it. First I installed WAMPserver and had the problem, so instead of that i decided to try isntalling all that manually and still the same problem. The code works flawlessly on our LAMP server but since I'm trying to make a separate development environment (the servers are going to production) and I'd really love to be able to run this all on my XP desktop. There are no errors whatsoever on the page or in the logs. Error reporting is working, i tested it. Tried to poke around output buffer size without any results. To put it short... this: <?php $foo="bar"; ?> <html><body>blargh<br /> <?="blargh back with a bit of $foo";?> </body></html> outputs this in to browser: <html><body>blargh<br /> <?="blargh back with a bit of $foo";?> </body></html> I must be missing something here... But can't figure it out. please help! Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/ Share on other sites More sharing options...
trq Posted January 27, 2009 Share Posted January 27, 2009 You might try using the full php tags instead of the shortended versions. <?php $foo="bar"; ?> <html><body>blargh<br /> <?php echo "blargh back with a bit of $foo";?> </body></html> Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-747504 Share on other sites More sharing options...
octacube Posted January 27, 2009 Author Share Posted January 27, 2009 missed the point. that's just a small example to simplify the problem i'm having... Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-747537 Share on other sites More sharing options...
trq Posted January 27, 2009 Share Posted January 27, 2009 The point is, php code will not be outputed unless your server is misconfigured. Did you try using the full tags? Does the problem persist? Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-747613 Share on other sites More sharing options...
haku Posted January 27, 2009 Share Posted January 27, 2009 If the code inside the short tags is printing out, its because your server is set to not parse short tags (<?). Which is why you shouldn't use them - they won't work on some servers, which makes your code unportable. It's generally considered sloppy coding. Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-747639 Share on other sites More sharing options...
octacube Posted January 28, 2009 Author Share Posted January 28, 2009 oh right ok. i get it now. thanks a lot. it's a portability problem from my sloppy coding... too bad if i'll have to change all the code from my several hundred of files with tens of thousands of lines of code. any workaround to get my sloppy coding to work? Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-748266 Share on other sites More sharing options...
5kyy8lu3 Posted January 28, 2009 Share Posted January 28, 2009 oh right ok. i get it now. thanks a lot. it's a portability problem from my sloppy coding... too bad if i'll have to change all the code from my several hundred of files with tens of thousands of lines of code. any workaround to get my sloppy coding to work? if you felt unusually cleaver you could write a php script to replace <? with <?php EDIT: i meant in each of your files, if that was unclear lol, something along the lines of opening a stream, opening the file, load it into a string, use something like str_replace('<?', '<?php', $string); or something, close it, move on to the next, lol, it would take a bit of work but could save you some time if you have hundreds of files you need to do that to Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-748269 Share on other sites More sharing options...
octacube Posted January 28, 2009 Author Share Posted January 28, 2009 i could do that. but i'd rather not. at least not at the moment. we're not porting this code to anywhere and for now i'm happy if it works in our production environment. I know i've done a ton of other sloppy php coding stuff too and when we're gonna remake the code i'll have to fix them all. If there isn't some settings trick on WAMP setup i'm gonna just go and not use WAMP setup then... this is really silly anyway... i've been coding with php for work for 3 years now and this is the first time anyone says that i have to use full php opening tag everytime all the examples i've come across have always been sloppy then... anyway... i'm not here to rant... crap happens, i've learnt that long time ago. So in short, any configuration trick that would do this or am i safer with going to LAMP? How to set the server to parse the short tags? Silly thing is that the same setup i'm using now worked on my mom's laptop during the holidays Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-748272 Share on other sites More sharing options...
octacube Posted January 28, 2009 Author Share Posted January 28, 2009 SOLVED Thanks everyone for kicking me in to right direction! in php.ini there's a short_open_tag setting which i had off and it's (for me) supposed to be on. Link to comment https://forums.phpfreaks.com/topic/142618-php-stops-executing-code-after-first-output-to-browser/#findComment-748274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.