Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Je désire utiliser un str_replace sur une variable qui contient le
résultat d'une commande system().

Bizarrement le STR_REPLACE semble sans effet

exemple de mon code

$entree = system('ls') ;
$sortie = str_replace(".php","",$entree) ;
echo $sortie

Une idée du pourquoi ?

Re: Fonction STR_REPLACE wrote:

First of all, this is an English-speaking newsgroup. Do not
expect answers speaking in any other language (you *could*
get an answer, just don't *expect* one; there's also a
significant drop in your chances to get a *helpful*

Quoted text here. Click to load it

There's nothing really 'bizarrement' about that. If only
you had read the docs, you would notice that system() is
described as follows: 'system -- Execute an external
program and display the output'.

Quoted text here. Click to load it

See above.

Okay, what you need is backticks.

$entree = `ls` ;

Next time, read the docs. There is even a French version of
PHP Manual if you want convenience, although I would advise
against using that.

Pavel Lepin

Re: Fonction STR_REPLACE

Thank you for your answer,

Just for your information, i've read the doc but as i'm just beginning
with php i don't understand everything as soon as i read the doc, sorry
for this.

Anyway, i still don't understand because if my variable stores the
result of the system output for me there's no difference with a text

let's imagine the result of the ls command is "myfile.php", then what
is the difference between :

$brut = system('ls')
$brut = ""

I imagine it's easy for you but i can assure you that i've read the doc
and it still doesn't make sense for me.

Site Timeline