Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function preg_quote()

previous

Advertisements

Syntax

string preg_quote ( string $str [, string $delimiter] );

Definition and Usage

preg_quote() takes str and puts a backslash in front of every character that is part of the regular expression syntax.

Return Value

  • Returns the quoted string.

Example

Following is the piece of code, copy and paste this code into a file and verify the result.

<?php

$keywords = '$40 for a g3/400';
$keywords = preg_quote($keywords, '/');
echo $keywords;

?>

This will produce following result.

\$40 for a g3\/400


previous Printer Friendly

Advertisements


  

Advertisements