Skip to content

Instantly share code, notes, and snippets.

@kunit
Created January 21, 2011 08:21
Show Gist options
  • Save kunit/789413 to your computer and use it in GitHub Desktop.
Save kunit/789413 to your computer and use it in GitHub Desktop.
最低限度のもの
<?php
class Escaper {
public $value = null;
public $raw = null;
public function __construct($value, $charset = 'UTF-8') {
$this->value = htmlspecialchars($value, ENT_QUOTES, $charset);
$this->raw = $value;
}
public function __toString() {
return $this->value;
}
}
$test1 = '<span id="str1">str1</span>';
$escaper = new Escaper($test1);
echo $escaper . "\n";
echo $escaper->raw . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment