3

This question already has an answer here:

What is the ` character's name and what is its significance outside of SE code formatting because I cannot get it to work? I'm familiar with its use in the Stack Exchange forums used to format code blocks, so please outside of that.

marked as duplicate by jasonwryan, derobert, goldilocks, slm, Mikel Apr 8 '14 at 0:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    "outside of that" Outside of that? Pretty vast, realm, I think. E.g. it's supposed to represent the "grave accent" used in various human languages. Narrowing it down to obviously *nix related things, it was historically used in a lot of (still existing) documentation in place of an opening single quote so that when translated to a paper format there was a way to distinguish the opening from closing quote (e.g. `like this'). Etc. If you want an answer, provide an example of what you are referring to. – goldilocks Apr 8 '14 at 0:20
  • @TAFKA'goldilocks' please see edit – 1'' Apr 8 '14 at 1:08
  • 1
    this question appears to be off topic because it is about PHP programming. – strugee Apr 8 '14 at 1:19
  • You're better off asking about PHP on Stack Overflow. – goldilocks Apr 8 '14 at 1:34
8

The ` has been called many things including a back-tic, backquote, inverted comma, quasiquote, and grave accent.

It is important to note that quotes, tics, and the like affect how the shell treats variables. When used incorrectly your results may vary or you may just get errors.

When forming complete expressions you should enclose them in `` like so:

val=`expr 3 + 4`

A more detailed description across a variety of different applications are included below.

The grave accent ( ` ) is a diacritical mark used in many written languages.

Programmers have used the grave accent symbol as a separate character (i.e., not combined with any letter) for a number of tasks. In this role, it is known as a backquote or back-tick.

When using TeX to typeset text, the back-tick character is used as a syntax to represent curly opening quotes. For example, ` is rendered as single opening curly quote (‘) and `` is a double curly opening quote (“).

It is also used for supplying the numeric ASCII value of an ASCII character wherever a number is expected.

Many of the Unix shells and the programming languages Perl, PHP, and Ruby use pairs of this character to indicate command substitution, that is, substitution of the standard output from one command into a line of text defining another command. For example, the code line:

echo It is now `date`

might result, after command substitution, in the command:

echo It is now Sun Apr 6 05:37:06 GMT 2014

which then on execution produces the output:

It is now Sun Apr 6 05:37:06 GMT 2014

It is sometimes used in source code comments to indicate code, e.g.

Use the `printf()` function.

This is also the format used by the Markdown formatter to indicate code.

Though you mentioned outside of Stack Exchange I thought it was important for those who are not aware that this is how Stack Exchange indicates code within questions, answers, and comments across each of its forums.

In the Bash shell, the `…` syntax is not recommended by style guides (though it is not formally deprecated), and the alternate syntax $(…) is preferred because it is more readable, especially for nested expressions. The same is true of Z shell.

In BBC BASIC, the back-quote character is valid at the beginning of or within a variable, structure, procedure or function name.

In D and Go, the back-quote is used to surround a raw string literal.

In Haskell, surrounding a function name by back-quotes allows it to be used as an infix operator.

In Lisp macro systems, the back-quote character (called quasiquote in Scheme) introduces a quoted expression in which comma-substitution may occur. It is identical to the plain quote, except that symbols prefixed with a comma will be replaced with those symbols' values as variables. This is roughly analogous to the Unix shell's variable interpolation with $ inside double quotes.

In m4, it is used together with an apostrophe to quote strings (to suppress or defer macro expansion).

In MySQL, it is used in queries as a column, table and database classifier.

In OCaml, the back-quote is used to indicate polymorphic variants.

In Pico, the back-quote is used to indicate comments in the programming language.

Prior to Python 3.0, back-ticks were used as a synonym for the repr() function, which converts its argument to a string suitable for a programmer to view. However, this feature was removed in Python 3.0.

Back-ticks are also used extensively in the reStructuredText plain text markup language (implemented in the Python docutils package).

Windows PowerShell uses the back-quote as the escape character. For example, a newline character is denoted `n. Most commonly used programming languages use a backslash as the escape character (e.g. \n) but because Windows allows the backslash as a path separator, it would have been impractical for PowerShell to use backslash for a different purpose. To get the ` character itself, two back-ticks are used.

For example, the nullable boolean of .NET is specified in PowerShell as:

[Nullable``1[System.Boolean]]

In Tom, the backquote is used to create a new term or to call an existing term.

In Scala an identifier may also be formed by an arbitrary string between back-quotes. The identifier then is composed of all characters excluding the back-quotes themselves.

In Unlambda, the back-quote character denotes function application.

http://en.wikipedia.org/wiki/Grave_accent

  • 2
    I'm fairly sure ` has been deprecated by POSIX. I'm not 100% sure, though. – strugee Apr 8 '14 at 0:37
  • @strugee - not according to the current [guidelines][1]. les - this is a really good answer. I've seen two of your questions lately, and this answer. I think you're getting a raw deal, but probably it's just luck. In any case, this one is a little broad for the intended audience I guess. But probably you should ask a question at so yourself and post this as an answer. Worst case it goes the same way this does - best case someone comes along and does better and you learn something. This is good though. [1]: pubs.opengroup.org/onlinepubs/9699919799/utilities/… – mikeserv Apr 8 '14 at 2:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.