php -r

php -r

am 06.01.2008 15:27:17 von Daniel Klein

Does anyone have a simple example of using 'php -r ' ?

I had thought that this would work...

C:\>php -r echo "test";
PHP Parse error: syntax error, unexpected $end in Command line code
on line 1

But as you can see, it doesn't. I've tried Google'ing the answer to no
avail.

I'm using Windows/Apache/MySQL and:

PHP 5.2.5 (cli) (built: Nov 8 2007 23:18:51)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


Daniel Klein

Re: php -r

am 06.01.2008 15:31:59 von Courtney

Daniel Klein wrote:
> Does anyone have a simple example of using 'php -r ' ?
>
> I had thought that this would work...
>
> C:\>php -r echo "test";
> PHP Parse error: syntax error, unexpected $end in Command line code
> on line 1
>
> But as you can see, it doesn't. I've tried Google'ing the answer to no
> avail.
>
> I'm using Windows/Apache/MySQL and:
>
> PHP 5.2.5 (cli) (built: Nov 8 2007 23:18:51)
> Copyright (c) 1997-2007 The PHP Group
> Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
>
>
> Daniel Klein
Not sure but shouldn't there be some pairs in there somewhere?

Re: php -r

am 06.01.2008 16:08:21 von luiheidsgoeroe

On Sun, 06 Jan 2008 15:27:17 +0100, Daniel Klein
wrote:

> Does anyone have a simple example of using 'php -r ' ?
>
> I had thought that this would work...
>
> C:\>php -r echo "test";
> PHP Parse error: syntax error, unexpected $end in Command line code
> on line 1

As always, if you have a space in your command line argument, you should
quote it, so either:
php -r "echo 'test';"

or

php -r echo('test');

--
Rik Wasmus

Re: php -r

am 06.01.2008 16:10:57 von Toby A Inkster

Daniel Klein wrote:

> I had thought that this would work...
>
> C:\>php -r echo "test";

You need to escape certain characters from the shell. For most Linux
shells you could use:

php -r echo\ \"test\"\;

or (slightly easier on the eye):

php -r 'echo "test";'

Not sure what it would be on Windows, but give those two a whirl.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 7 days, 2:22.]

dhyana.pl/0.3
http://tobyinkster.co.uk/blog/2008/01/06/dhyana/

Re: php -r

am 06.01.2008 16:11:05 von Jonas Werres

> Not sure but shouldn't there be some pairs in there somewhere?

No, there should never be any around anywhere. Shorttags are evil.

Re: php -r

am 06.01.2008 18:09:07 von Dikkie Dik

> php -r 'echo "test";'
>
> Not sure what it would be on Windows, but give those two a whirl.

On windows, change the quotes:
php -r "echo 'test';"