“PHP Escape Caracteres especiales” Código de respuesta

PHP despoja caracteres especiales

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

Determinar caracteres especiales en PHP

<?php

$string = 'foo';

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

PHP Escape Caracteres especiales

/*  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 Caracteres especiales PHP

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

Respuestas similares a “PHP Escape Caracteres especiales”

Preguntas similares a “PHP Escape Caracteres especiales”

Más respuestas relacionadas con “PHP Escape Caracteres especiales” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código