“PHP Escape Special Postacie” Kod odpowiedzi

PHP Stradzi znaki specjalne

function clean($string) {
   $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.

   return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
Courageous Cod

Określ znaki specjalne w PHP

<?php

$string = 'foo';

if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $string))
{
    // one or more of the 'special characters' found in $string
}
Alive Antelope

PHP Escape Special Postacie

/*  EXAMPLE:	<p>Bed & Breakfast</p>	-->	  <p>Bed &amp; Breakfast</p>  
    & 	&amp;
    " 	&quot; 				(unless ENT_NOQUOTES is set)
    ' 	&#039; or &apos; 	(ENT_QUOTES must be set)
    < 	&lt;
    > 	&gt;				*/

<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; 					// <a href='test'>Test</a>
?>
VasteMonde

HTML PHP PHP

$string = "This is testing message "ETC" ";
htmlspecialchars($string, ENT_COMPAT)

Odpowiedzi podobne do “PHP Escape Special Postacie”

Pytania podobne do “PHP Escape Special Postacie”

Więcej pokrewnych odpowiedzi na “PHP Escape Special Postacie” w PHP

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu