Chopping off .phps files?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
enygma
Site Admin
Posts: 175
Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx

Chopping off .phps files?

Post by enygma »

Alright, I have to admit - I'm stumped.

Check out these links:
http://www.phpdeveloper.org/feedback_class.phps
http://www.phpdeveloper.org/xml_class.phps
http://www.phpdeveloper.org/amazon_class.phps

Now, the common thread - they all get chopped off before the bottm. (And yes, I made sure they were all there...) The files on the server are intact, but I can't get Apache to show them all for some reason....

Has anyone else ever seen this? And how did you fix it?
thanks.....
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

I have seen a somewhat similar problem on some older build of php when writing very long strings to files. If the formatter is written in php you might want to see if you can make it echo/output the formatted code in chunks instead of all at once (if that's what its doing) It shouldn't be a problem in newer versions of php(at least according to the developers) but I've left my "chunked" code in my pages.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

One other tought, viewing the source html it appears there there are no newlines in the entire document. Perhaps apache is having trouble dealing with a single line that long?
User avatar
enygma
Site Admin
Posts: 175
Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx

Post by enygma »

well, normally, you can just make the file a .phps copy of the origional and apache/PHP handle the output.

but that might be it....too bad i cant control it.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

my version of php adds in new lines...it seems to run it through nl2br() or something. at every break in the code i see:

Code: Select all

code..
<br />
code..
so im going to go with the idea that apache can't handle a line that long being generated..php or apache
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

But doesn't apache still know to hand off the execution of .phps script to another specified script to generate the pretty-printing? (Ie the input phps script is identical to the main .php (often a symlink, right) and apache knows nothing about pretty-printing so some script on your server is creating the returned page.

It might be as simple as inserting a \n after every <br /> or something like

Code: Select all

$len= strlen($wholePage);
$numBlocks = $len/512;
for ($i=0;$i<$numBlocks;$i++)
&#123;
    echo substr($wholePage,$i*512,512);
&#125;
If you could provide a pointer to the script youre using to generate the markup, I'ld happily take a look.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

So I've dug around on the php.net site to look at how they appear to be doing it and how they suggest doing it (often different), their pages appeae to have the same all source=one line of text affect, but most of their pages are quite short.

What version of php are you running? I can force a similar problem on one of my machines that has an ancient version, 4.0.4.
User avatar
enygma
Site Admin
Posts: 175
Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx

Post by enygma »

that's just it - i'm not passing it off to a script.
The .phps file is a native thing for PHP - it handles it on it's own as long as the AddType is in the Apache conf. On all my other machines, it works just fine....I make the .phps symlink and it shows the entire file just fine in the browser.

But, for some reason this one doesn't want to cooperate. I hacked around it for my purposes, but I've heard from other people that this is a bug that other people have seen since PHP 4.1.2
Post Reply