This code is 95% cut and paste from the PHP manual examples -
the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
There are actually two questions here - I have combined the code into
one test file ... the strings in the code contain the questions ..
at the end I have inserted the output I get from the code - identical in
Firefox and IE8 (so it's not browser related), and on my desktop as well
as my laptop (so it's not a machine quirk). The setup is Xammplite
Win32-1.7.1 with PHP 5.2.9 and Apache 2.2.11 on both WinXP-SP3 installs.
I tried Xammp Win32-1.7.3 with the same results. Then I tried installing
Apache and PHP and MySQL individually, and got the same ...
Aside from the issue here, I also was unable to get imagick and xdebug
running on the same installation - it was one or the other. imagick's
readfile() caused Apache to baulk on PHP5.3.3, so I returned to a fresh
Xammplite setup. Same results.
I have spent many hours with this - I would appreciate some insight ..
Question 1 : how to get the newline functioning ....? even print_r()
output is not 'newlined' as it should be. Also note the \n is missing
between the " " in the output text of the second test!
Question 2 : fnmatch() is an internal function (ie built in to PHP, yet
get_defined_functions() does not find it. Perhaps there are others also
missing, I haven't done a check - could it be a compile error in
Xammplite's PHP binaries?
-----------------------------------------------------------------
heredoctest.php = the // comments are not in the actual file ...
-----------------------------------------------------------------
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
(this code cut and paste from
the PHP manual examples ...
it just will not work ...!
EOD;
echo $str . "\n"; //echoes the string, fails on newlines in heredoc
// content and in this newline
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
// again no newlines on direct heredoc echo ...
echo <<<HDOC
a second test for newlines - "\n" - can't find what is required to
get this to work - have tried everything in the PHP Manual
- still nothing - amazingly even Heredocs does not work.
Tried this on two machines - both running Xammplite 1.7.1. Also
tried installing PHP5.3.3 - and Newdocs doesn't work either. Any ideas?
HDOC;
//note the n gets escaped, but no actual newline occurs in the output
// and the " " gets left in the output!
/* And for good measure, here is another bit of frustration - also
code copied directly from the manual ...
'fnmatch' is an internal function - yet PHP can't find it ... */
echo "some form of gray ...\n ... or grey"; // no newline in output
if (fnmatch("*gr[ae]y", $color)) { // function undefined, dies
echo "some form of gray ...\n ... or grey";
}
?>
-----------------------------------------------------------------
Here's the output: - the line breaks are non-existent - here, of course
the wrapping is imposed by the mail client editor, but in the browser it
just it all just runs together .. most curious, very frustrating.
-----------------------------------------------------------------
Example of string spanning multiple lines using heredoc syntax. (this
code cut and paste from the PHP manual examples ... it just will not
work ...! My name is "MyName". I am printing some Foo. Now, I am
printing some Bar2. This should print a capital 'A': Aa second test for
newlines - " " - can't find what is required to get this to work - have
tried everything in the PHP Manual - still nothing - amazingly even
Heredocs does not work. Tried this on two machines - both running
Xammplite 1.7.1. Also tried installing PHP5.3.3 - and Newdocs doesn't
work either. Any ideas?some form of gray ... ... or grey
Fatal error: Call to undefined function fnmatch() in
C:\xammplite\htdocs\heredoctest.php on line 47
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php