當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inspekt::useFilterExt方法代碼示例

本文整理匯總了PHP中Inspekt::useFilterExt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inspekt::useFilterExt方法的具體用法?PHP Inspekt::useFilterExt怎麽用?PHP Inspekt::useFilterExt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inspekt的用法示例。


在下文中一共展示了Inspekt::useFilterExt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testUseFilterExt

 /**
  * 
  */
 public function testUseFilterExt()
 {
     $this->assertTrue(Inspekt::useFilterExt(true));
     $this->assertTrue(Inspekt::useFilterExt());
     $this->assertFalse(Inspekt::useFilterExt(false));
     $this->assertFalse(Inspekt::useFilterExt());
 }
開發者ID:vkoser,項目名稱:PlainNoteServer,代碼行數:10,代碼來源:InspektTest.php

示例2: noTagsOrSpecial

 /**
  * returns value with tags stripped and the chars '"&<> and all ascii chars under 32 encoded as html entities
  * 
  * This will utilize the PHP Filter extension if available
  * 
  * @param mixed $value
  * @return @mixed
  * 
  * @tag filter
  * 
  */
 public static function noTagsOrSpecial($value)
 {
     if (Inspekt::isArrayOrArrayObject($value)) {
         return Inspekt::_walkArray($value, 'noTagsOrSpecial');
     } else {
         if (Inspekt::useFilterExt()) {
             $newval = filter_var($value, FILTER_SANITIZE_STRING);
             $newval = filter_var($newval, FILTER_SANITIZE_SPECIAL_CHARS);
             return $newval;
         } else {
             $newval = strip_tags($value);
             $newval = htmlspecialchars($newval, ENT_QUOTES, 'UTF-8');
             // for sake of simplicity and safety we assume UTF-8
             /*
             	convert low ascii chars to entities
             */
             $newval = str_split($newval);
             for ($i = 0; $i < count($newval); $i++) {
                 $ascii_code = ord($newval[$i]);
                 if ($ascii_code < 32) {
                     $newval[$i] = "&#{$ascii_code};";
                 }
             }
             $newval = implode($newval);
             return $newval;
         }
     }
 }
開發者ID:a-optic,項目名稱:inspekt_light,代碼行數:39,代碼來源:Inspekt.php

示例3: var_dump

<?php

/**
 * Demonstration of:
 * - use of static filter methods on arrays
 * - creating a cage on an arbitrary array
 * - accessing a deep key in a multidim array with the "Array Query" approach
 */
require_once '../Inspekt.php';
Inspekt::useFilterExt(false);
echo "<p>Filtering an arbitrary array using Inspekt::noTags()</p>\n\n";
$d = array();
$d['input'] = '<img id="475">yes</img>';
$d['lowascii'] = '    ';
$d[] = array('foo', 'bar<br />', 'yes<P>', 1776);
$d['x']['woot'] = array('booyah' => 'meet at the bar at 7:30 pm', 'ultimate' => '<strong>hi there!</strong>');
$d['lemon'][][][][][][][][][][][][][][] = 'far';
echo "<pre>BEFORE:";
echo var_dump($d);
echo "</pre>\n";
$newd = Inspekt::noTags($d);
echo "<pre>noTags:";
echo var_dump($newd);
echo "</pre>\n";
$newd = Inspekt::noTagsOrSpecial($d);
echo "<pre>noTagsOrSpecial:";
echo var_dump($newd);
echo "</pre>\n";
$newd = Inspekt::getDigits($d);
echo "<pre>getDigits:";
echo var_dump($newd);
開發者ID:a-optic,項目名稱:inspekt_light,代碼行數:31,代碼來源:filter_array.php


注:本文中的Inspekt::useFilterExt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。