Using backstick in PHP

  • Carol
  • Newbie
  • Newbie
  • Carol
  • Posts: 14
  • Loc: Indonesia

Post 3+ Months Ago

I aready set safe_mode become off but I still cannot use backstick in PHP. Example:This command does not give result: echo `ls -la`;
Could you help me?
Thanks
Carol
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Not without seeing your source :)
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

You mean you wish to use ` instead of '? or what? this won't work:

PHP Code: [ Select ]
 
<?
 
echo `Hello World!`;
 
//but this will:
 
echo 'Hello World';
 
//so will this:
 
echo "Hello World";
 
?>
 
 
  1.  
  2. <?
  3.  
  4. echo `Hello World!`;
  5.  
  6. //but this will:
  7.  
  8. echo 'Hello World';
  9.  
  10. //so will this:
  11.  
  12. echo "Hello World";
  13.  
  14. ?>
  15.  
  16.  
  • Carol
  • Newbie
  • Newbie
  • Carol
  • Posts: 14
  • Loc: Indonesia

Post 3+ Months Ago

I read in PHP manual that I can use command with backstick. Example like this:
<?php
echo `ls -la`;
?>
but when I run it, it has no response. So I worry is there any condition to run that command. (It is backstick not single quote)
Please help me once again.
Thanks.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

Could you show me the page you saw that on? I've never heard of being able to use backsticks instead of quotes. I'll go look but I am doubtful.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

The manual doesn't show any support for delimiting strings with backsticks. See here:
http://www.php.net/manual/en/language.types.string.php

Nor does the echo function have any "special" features allowing backsticks, or non stated.

I have never, in over two years seen backsticks in place of quotes.
  • Carol
  • Newbie
  • Newbie
  • Carol
  • Posts: 14
  • Loc: Indonesia

Post 3+ Months Ago

I didnot have mean that can use backstick instead of quote. I say again my problem is I use backstick but it has no response, I worry someone will think backstick (`) is single quote(') so I aready said that it is backstick not quote. Please read it again.
Do you understand I mean?
So do you know how can I run that command?
Thanks so much
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

Well, I couldn't find any support for backstick (like shell backstick) in PHP site.

popen() will solve your problem instead. Take a look to this manual page -> http://ar2.php.net/manual/en/function.popen.php
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

Well I just realised you were using Ls and not is (as in the word). So I didn't realize you were trying to run the command. echo does not run commands, it only outputs data, and that is done either through the returned value of a function, value of a variable, or value contained in the string.

Like I said, I have never seen backstick's used in php. The only time I've ever used them is to make my mysql queries neater, and they are nested inside of quotes which makes it just like any other of the 255 characters.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: Bogey and 93 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.