Asked  7 Months ago    Answers:  5   Viewed   46 times

I am trying to generate an XML file in a PHP web application:

header('Content-Type: application/xml');
header('Content-Disposition: attachment; filename=test.xml');
echo "<?xml version="1.0"?>rn" . 

Bizarrely, when using my servers (PHP Version 5.3.8/Apache 2.2.17 and PHP Version 5.3.10-1/Apache 2.2.22 respectively) a line feed (hex 0a) character is inserted in the beginning of the output, resulting in invalid XML that cannot be used. There's one more online question about this, unresolved.

So if I try echo "bug"; I get 4 bytes, not 3: 0a 62 75 67

However, when using WAMP server locally (PHP 5.4.3/Apache 2.4.2), I get 3 bytes: 62 75 67.

  • Is this a known bug/feature?
  • Is it a configuration issue?
  • Which is to blame, Apache or PHP?
  • Do I have to upgrade my servers? I'd rather not.



It seems like the 0a problem was caused by a trailing Enter character in a PHP file included by my main PHP file. When I removed it from the include file, the 0a character in my output disappeared.

What I find peculiar about this is the different handling of whitespace between PHP versions that I experienced, and the fact that I still got the 0a when testing the community's suggestions.

I have no more time to put research into this, but my advice to people experiencing similar problems is to check whether whitespace in include files may play into the equation. In addition, avoid ending the <?php tag as suggested by Dan below.

Saturday, May 29, 2021
answered 7 Months ago

I did this yesterday using mod_auth_kerberos. Basic process is as follows:

  1. Install kerberos and configure

  2. On active directory create a new user

  3. Use ktpass on windows to create a keytab

  4. Copy keytab to ubuntu and configure apache to use keytab

Have a look at the documentation here: It explains the configuration files better than I ever could.

Ubuntu specific bits are probably just installation, for which you'll want:

sudo apt-get install krb5-user libapache2-mod-auth-kerb
Wednesday, March 31, 2021
answered 9 Months ago

First of all, what is the version of PHP?

If other .php scripts work except for phpMyAdmin, the is pretty safe to assume something is wrong with phpMyAdmin installation. (either with the files or the Virtual Host)


  1. Can you run another script in phpMyAdmin directory? Try with a file containing phpinfo(); If it does not work then the problem is in your apache configuration.

  2. If the above is true, then the parser is not recognising phpMyAdmin/index.php as a php file, for some reason. Try reinstalling phpMyAdmin.


Remove AddType application/x-httpd-php .php. You should not need it.

In PHP 5.4 magic_quotes_gpc was removed. If you're running PHP5, remove that line.

As of PHP 4.0.3, track_vars is always turned on, so remove it also.

As of PHP 4.2.0, register_globals this directive defaults to off. In PHP5.3 register_globals is deprecated, as of PHP5.4 register_globals was removed. SO if running PHP > 4.2.0 remove that line.

Saturday, May 29, 2021
answered 7 Months ago

You put me on the right track but there was kinddof a problem (I love Windows o/) :

C:php>chcp 65001
Page de codes active : 65001
C:php>php -c C:WINDOWSphp.ini -f mysqldump.php | more
Mémoire insuffisante.

Mémoire insuffisante = not enough memory.

If I try

C:php>chcp 1252
C:php>php -c C:WINDOWSphp.ini -f mysqldump.php

it works. Only God knows why. But it works. Thanks for putting me on the right track !!

By the way the php code to go properly form UTF8 to command prompt is :

  echo mb_convert_encoding($utf8_string, "pass", "auto");
Thursday, July 29, 2021
answered 5 Months ago

Use "rn". (with double quotes)

The above is the ascii characters for carriage return + line feed.

Historically this relates to the early days of computing on teletypes when the output was printed to paper and returning the carriage of the teletype head to the start of the line was a separate operation to feeding a line through the printer. You could overwrite lines by just doing a carriage return and insert blank lines by just a line feed. Doing both returned the head to the start of the line and fed it a new line to print on.

What precisely was required differed between systems -

  • Line feed only: - most Unix like systems
  • Carriage return plus Line feed: - DEC amd MS-DOS based systems
  • Carriage return only: - Early Apple/Mac OS's

So what you're generating at the moment is a newline on a Unix system only. Wikipedia has quite a good page on this.

There's actually unix command line tools to do the conversion too. The unix2dos and dos2unix commands convert ascii text files back and forward between the unix and dos formats by converting line feed to line feed plus carriage return and vica versa.

Monday, September 20, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :