Re: whoami explanation

From: Date: Tue, 03 Mar 2009 15:47:39 +0000
Subject: Re: whoami explanation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-289129@lists.php.net to get a copy of this message
On Tue, 2009-03-03 at 10:42 -0500, PJ wrote: > This really needs some explanation > I found this on the web: > <?php echo whoami; ?> > with it there was the comment "the direction of those single-quotes matters" > (WHY ?) > and it works.... > > But this (_*FROM THE PHP MANUAL***_ * - exec()* executes the given > /command/ ) does not, > COPIED AND PASTED: > |<?php > // outputs the username that owns the running php/httpd process > // (on a system with the "whoami" executable in the path) > echo exec('whoami'); > ?> | > What is going on here? > And I often find such discrepancies in examples - and some wonder why I > seem to be so stupid... and don't know the fundamentals... :-\ Those are backticks. They execute a program via the shell. If you drop to the shell and type whoami at the prompt you will get the same result. The backticks operator returns the shell's output which is why it can be echoed. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#289129) next »