Jump to content

PHP stops executing code after first output to browser


octacube

Recommended Posts

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!

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.

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?

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  ;D

 

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

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 :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.