PJ wrote:
> Per Jessen wrote:
>> PJ wrote:
>>
>>   
>>> forgot to add:
>>> What's the difference between back ticks or quotes and regular single
>>> quotes?
>>>     
>> text in back ticks is executed via a shell, text in single quotes isn't.
>>   
> Ok, but how does this relate to a command passed from a php Web page?
> I don't understand the processus.
> I use bash on my FreeBSD and have not needed a back quote yet that I can
> recall... and on WinXP?

In your bash shell, you can use backticks in a similar way to how PHP uses them
- to assign the output of a command to a variable. For example:

LIST=`find . -name '*.php'`

will fill up the shell variable $LIST with all the files with extension .php
below the current directory.
You could then do something with that variable, like

for FILE in $LIST
do
        cp $FILE $FILE.bak
done

to make a backup copy of each of the files.

In PHP, something like

<?php
$list = `find . -name '*.php'`;
foreach (explode(' ',$list) as $file)
{
        copy ($file,"{$file}.bak");
}
?>
should do much the same thing (if permissions etc. allow...)

Note that in both of these examples, filenames with spaces in them will blow the
whole thing up :(


-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to