Oihana PHP

isQuoted.php

Table of Contents

Functions

isQuoted()  : bool
Checks whether a string is wrapped in a matching pair of quote characters.

Functions

isQuoted()

Checks whether a string is wrapped in a matching pair of quote characters.

isQuoted(string $value) : bool

Recognised pairs (symmetric and asymmetric):

  • '…' single quotes
  • "…" double quotes
  • `…` backticks
  • «…» French guillemets
  • “…” English typographic double quotes
  • ‘…’ English typographic single quotes / apostrophe

Returns false when the value is shorter than the pair, or when only one side is quoted.

Parameters
$value : string

The string to test.

Tags
example
isQuoted('"hello"'); // true
isQuoted("'hello'"); // true
isQuoted('«hello»'); // true
isQuoted('"hello');  // false (unmatched)
isQuoted('hello');   // false
isQuoted('""');       // true (empty quoted string)
isQuoted('"');        // false (too short)
author

Marc Alcaraz

since
1.0.8
see
unquote()
getQuoteChar()
Return values
bool

true if the value starts AND ends with a matching pair.

On this page

Search results