quotemeta funksiýasy

quotemeta funksiýasy setirde her bir ýörite nyşanyň öňüne backslash goşýar. Aşakdaky nyşanlar goralan: . \ + * ? [ ^ ] ( $ ). Funksiýa işlenjek setir bolan ýeke-täk parametr kabul edýär.

Sintaksis

phpquotemeta(string);

Mysal

Ýöňňe setirde ýörite nyşanlary goralama:

php<?php
  echo quotemeta('Hello.world (test)');
?>

Kody ýerine ýetirmek netijesi:

php'Hello\.world \(test\)'

Mysal

Birnäçe ýörite nyşany öz içine alýan setiri goralama:

php<?php
  echo quotemeta('1+1=2? [maybe]');
?>

Kody ýerine ýetirmek netijesi:

php'1\+1\=2\? \[maybe\]'

Mysal

Ýörite nyşany ýok setiri işlemek:

php<?php
  echo quotemeta('simple text');
?>

Kody ýerine ýetirmek netijesi:

php'simple text'

Şeýle-de serediň

  • addslashes funksiýasyny,
    setiri slash bilen goraýan
  • preg_quote funksiýasyny,
    regular ifadelerde nyşanlary goraýan