7

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.

1''
  • 357
  • 1
  • 4
  • 7
  • 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 08 '14 at 00:20
  • @TAFKA'goldilocks' please see edit – 1'' Apr 08 '14 at 01:08
  • 1
    this question appears to be off topic because it is about PHP programming. – strugee Apr 08 '14 at 01:19
  • You're better off asking about PHP on Stack Overflow. – goldilocks Apr 08 '14 at 01:34

1 Answers1

20

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

les
  • 581
  • 2
    I'm fairly sure ` has been deprecated by POSIX. I'm not 100% sure, though. – strugee Apr 08 '14 at 00: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]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03 – mikeserv Apr 08 '14 at 02:46
  • Some screen readers, like the one I use, pronounces the ` character as grahv. – HeavenlyHarmony Feb 26 '21 at 15:41