Re: Backtick call appends extra space
- From: Jeremy <jeremy@xxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 14:13:08 -0700
Martin wrote:
Look at the following code:
<?php
$year = `date +
%Y`;
echo "(".$year.")";
?>
The output is
(2008 )
There is an extra space after the "2008". Why is that, and what can I
do about it?
It's not a space, it's a linefeed (look at the source generated; the linefeed is converted to a space for presentation because of HTML whitespace rules). This will happen with pretty much any command line utility; they all must print a linefeed after their output to get your prompt on the following line.
And like Heiko Richler said - trim() the output and you shouldn't have any problems.
Jeremy
.
- References:
- Backtick call appends extra space
- From: Martin
- Backtick call appends extra space
- Prev by Date: Re: MIME file and gd
- Previous by thread: Backtick call appends extra space
- Next by thread: zend studio trial version cd
- Index(es):
Relevant Pages
|