Xampp or PHP removing line breaks

Alles, was PHP betrifft, kann hier besprochen werden.

Xampp or PHP removing line breaks

Postby jupiter2000 » 01. February 2009 16:57

I'm have a weird error. I have a website that I already created and hosting online. I started using Xampp so I could work on the site while offline and make/test changes in a safe non-online environment. Everything is going great...until I tried accesing my website pages that I have already created. The issue is very weird since its not happening with all the php pages. But basically either xampp or more than likely the PHP is removing line breaks / carriage return from some of my php code. I'm assuming its a change I need to make in the PHP.ini file since this does not happen on my webserver. Altho, since it's only happening with some php files, I'm beginning to think it might actually be an issue with the type of line break in the file.

First of all...I used NOTEPAD to create the php files. So I'm using a real text editor and not a format one like wordpad or something.

The only thing I can think of that MIGHT cause the issue in changing the type of line break is to make editing the php code on my website easy (without using a software program) i created a simple php webpage that can edit my php code on the fly. Basically that editor pulls the source code into a text box where i can edit the code and it will save the updates. So I'm wondering if the php code I already created properly in Notepad might be changed in some form when i use this editor to update the page source code. However...if this IS an issue...it must also be a configuration issue since my online website doesn't have any problem...I only noticed this problem when I started accessing those pages offline thru Xampp.

Now the problem:

I have an index.php page with the snippet code:
Code: Select all
<?php
   include_once $_SERVER['DOCUMENT_ROOT'] . '/inc.common.php';
?>


Now the index page is working fine...
HOWEVER the inc.common.php page starts with the following code:
Code: Select all
<?php
session_start();


The problem happens when I access index.php. As soon as I do it outputs an error: "Call to undefined function phpsession_start" in the inc.common.php file

Then I goto inc.common.php and open in notepad. While the code was originally spaced correctly, it now looks like a jumbled mess and looks like:
Code: Select all
<?phpsession_start()


For some reason...even though I'm not editing the php, only accessing the index php which includes the common file, it looks at my line breaks in the common file and removes them. I can actually re-edit the file and put a SPACE between php and session_start and it runs fine until then next error. I can even press a new line break and it works fine. But if I copy/paste the original code from notepad, it will repeat the error. However index.php is unchanged.

So it's clearly and issue between different types of line breaks or something like that ALONG with a configuration setting probably in php.ini that can be modified since my webserver doesn't do this.

Any ideas?

Basically I just need to find out either a) what configuration i can change to make like my webserver so it will ignore this or b) figure out why the line break is changing that is causing the issue so that I can make sure to stop creating this issue in the future and having to manually re-edit multiple pages. Obviously the latter B option is what I'd really like to do to make sure my code stays proper and concise.
jupiter2000
 
Posts: 2
Joined: 01. February 2009 16:35

Re: Xampp or PHP removing line breaks

Postby jupiter2000 » 01. February 2009 17:19

BTW...the only other difference between my webserver and xampp is that my webserver is running php 5.2.5 and i have updated to the newest xampp with php 5.2.8

So i'm not sure what configuration changes may have been made between the two builds. If there's a new option that might be causing this issue, I guess it's better I learn to fix it now before I update my webserver to the new build and start having just webpage visits render most of my code useless lol.
jupiter2000
 
Posts: 2
Joined: 01. February 2009 16:35


Return to PHP

Who is online

Users browsing this forum: No registered users and 2 guests