Fonction STR_REPLACE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alexandre.suc@gmail.com

    Fonction STR_REPLACE

    Bonjour

    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(".p hp","",$entre e) ;
    echo $sortie

    Une idée du pourquoi ?

  • p.lepin@ctncorp.com

    #2
    Re: Fonction STR_REPLACE


    alexandre.suc@g mail.com 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*
    answer).
    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
    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'.
    exemple de mon code
    >
    $entree = system('ls') ;
    $sortie = str_replace(".p hp","",$entre e) ;
    echo $sortie
    >
    Une idée du pourquoi ?
    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

    Comment

    • alexandre.suc@gmail.com

      #3
      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
      string.

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

      $brut = system('ls')
      and
      $brut = "myfile.ph"

      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.

      Comment

      Working...