Re: Re: require() causing strange characters ?

From: Date: Mon, 09 Feb 2009 14:46:35 +0000
Subject: Re: Re: require() causing strange characters ?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-287961@lists.php.net to get a copy of this message
Thanks Nisse, ----- Original Message ----- From: "Nisse Engström" <news.NOSPAM.0ixbtqKe@luden.se> To: <php-general@lists.php.net> Sent: Sunday, February 08, 2009 6:06 PM Subject: Re: [PHP] Re: require() causing strange characters ?
On Fri, 6 Feb 2009 10:11:49 +0100, cr.vegelin@gmail.com wrote:
I saved both scripts with ANSI in stead of UTF-8 and the problem is gone. So the utf-8 BOM character (Byte Order Mark) caused it. Unfortunately my editor has no option to store BOM-free scripts. Is it standard that PHP scripts should be saved without a BOM character ?
This is not a PHP matter, unless PHP 6 (which will have Unicode support) does something with it. PHP 5 just outputs it as is. A BOM character is supposed to be the *first* character in a text stream. Otherwise it should be treated as a ZERO WIDTH NON-BREAKING SPACE. <http://unicode.org/faq/utf_bom.html#bom1>
Test results ... If "test.php" (utf8) requires "echo.php" (utf8), page source has "C�testD", size 9 If "test.php" (ansi) requires "echo.php" (utf8), page source has "CtestD", size 7 If "test.php" (ansi) requires "echo.php" (ansi), page source has "CtestD", size 6 The reason for asking is that sometimes "" is displayed on some pages.
That means you've used a utf-8 BOM in a page using an 8-bit character encoding (eg. iso-8859-1 or similar), or that you have utf-8 encoded it twice. /Nisse
I've tested it again, from scratch with Notepad editor:
echoUTF8.php        <?php require("echoUTF8sub.php"); ?>
echoUTF8sub.php <?php echo "test"; ?> and keep getting strange characters. Would you be so kind to run these 2 scripts on your pc ? TIA, Cor

« previous php.general (#287961) next »