473,785 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ?

Sep 1 '06 #1
2 1460

al***********@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

Sep 1 '06 #2
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.

Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4608
by: Jon | last post by:
Why does the following not replace the ":)"? str_replace(":)", "&nbsp;<img src=http://www.com.com/forum/emoticons/smiley.gif>&nbsp;", $_POST); But, the following does replace the ":("? str_replace(":(", "&nbsp;<img src=http://www.com.com/forum/emoticons/crying.gif>&nbsp;", $_POST);
9
21566
by: Hugo Coolens | last post by:
I need to use the str_replace function for a php-script which works together with html/javascript. In the script I have to perform things like: $arabic=str_replace ("'","\'", $row); $arabic=str_replace ("sh", "\š", $row); the second line works perfectly, however I can't make the first one work, it should replace a single quote with a quote preceded by a backslash. I presume I have to escape some characters to make this happen however...
3
5233
by: Philippe Mesmeur | last post by:
J'ai eu une longue discussion hier au sujet des parametres de fonction const. La personne etait pour mettre "const" devant TOUS les parametres ne devant pas etre modifies. A mon avis, il faut le faire que SI le parametre est un pointeur ou une référence. int fct1(const int* i);
1
1679
by: marcomputers | last post by:
Hi, I'm trying to automatically update an existing rss podcast file using php and the str_replace function. Every time I add a media file, it should read the .rss file into a string, take the closing </channel> and </rss> tags out of it, and add the new rss file info to the end of the existing string, writing it back to the rss file. However, str_replace will not replace the </channel> and </rss> tags with ' '. I'm new to php, any help...
9
43160
by: Wayne | last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test $p = str_replace ("%0D%0A", "<br>", $a); That is the above code that I am using, however, it is not picking up the CR/LF from the textarea. I have also attempted singular variations of the CR/LF combination and even reversed the sequence without success. Is it possible that it may be encoded differently and if so what is it? Thanks
4
4578
by: The Numerator | last post by:
I have this page (print.php). In that file, I want to to include a text file from "songs/breathe.txt", and replace all instances of "<b" with "<span" and "</b>" with "</span>". I know how I should use str_replace and I tried to do this: <?php $replace_a=str_replace("<span","<b",include("text/breathe.txt")); $replace_b=str_replace("</span>",</b>",$replace_a);
4
3073
by: d1srupt3r | last post by:
I am developing my form into a captcha secured form and I used header() function if the user didn't put the verification code properly and still when the user go back to the form page the filled he have filled have still remained. In addition, users are usually submitting multiliner texts in the textbox so I used the str_replace() function to make all \n into %n% to prevent an error in the header function whenever the form is submitted. my...
5
1694
by: jmark | last post by:
I saw this example in php.net // Outputs: apearpearle pear $letters = array('a', 'p'); $fruit = array('apple', 'pear'); $text = 'a p'; $output = str_replace($letters, $fruit, $text); echo $output; and I am bit puzzled why the output is the way it is instead of
3
3446
by: Confused but working on it | last post by:
So I've been trying to get a bit of code to: Read all of the files in a dir called thumbs, but not the . and .., use the filename in a link to get the same filename in an images dir. Now I'm trying to use a foreach and glob as suggested, and get rid of the part of the string that has the dir info. SO the below produces all my thumbs nicely and all are links. <?php foreach (glob("thumbs/*.jpg") as $file) {
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.