当前位置: 首页>>代码示例>>PHP>>正文


PHP htmlspecialchars函数代码示例

本文整理汇总了PHP中htmlspecialchars函数的典型用法代码示例。如果您正苦于以下问题:PHP htmlspecialchars函数的具体用法?PHP htmlspecialchars怎么用?PHP htmlspecialchars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了htmlspecialchars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: vc_dropdown_form_field

/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
开发者ID:severnrescue,项目名称:web,代码行数:42,代码来源:default_params.php

示例2: dump

function dump($var, $echo = true, $label = null, $strict = true)
{
    $label = $label === null ? '' : rtrim($label) . ' ';
    if (!$strict) {
        if (ini_get('html_errors')) {
            $output = print_r($var, true);
            $output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
        } else {
            $output = $label . " : " . print_r($var, true);
        }
    } else {
        ob_start();
        var_dump($var);
        $output = ob_get_clean();
        if (!extension_loaded('xdebug')) {
            $output = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $output);
            $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES, "GB2312") . '</pre>';
        }
    }
    if ($echo) {
        echo $output;
        return null;
    } else {
        return $output;
    }
}
开发者ID:winiceo,项目名称:job,代码行数:26,代码来源:lib.php

示例3: submitInfo

 public function submitInfo()
 {
     $this->load->model("settings_model");
     // Gather the values
     $values = array('nickname' => htmlspecialchars($this->input->post("nickname")), 'location' => htmlspecialchars($this->input->post("location")));
     // Change language
     if ($this->config->item('show_language_chooser')) {
         $values['language'] = $this->input->post("language");
         if (!is_dir("application/language/" . $values['language'])) {
             die("3");
         } else {
             $this->user->setLanguage($values['language']);
             $this->plugins->onSetLanguage($this->user->getId(), $values['language']);
         }
     }
     // Remove the nickname field if it wasn't changed
     if ($values['nickname'] == $this->user->getNickname()) {
         $values = array('location' => $this->input->post("location"));
     } elseif (strlen($values['nickname']) < 4 || strlen($values['nickname']) > 14 || !preg_match("/[A-Za-z0-9]*/", $values['nickname'])) {
         die(lang("nickname_error", "ucp"));
     } elseif ($this->internal_user_model->nicknameExists($values['nickname'])) {
         die("2");
     }
     if (strlen($values['location']) > 32 && !ctype_alpha($values['location'])) {
         die(lang("location_error", "ucp"));
     }
     $this->settings_model->saveSettings($values);
     $this->plugins->onSaveSettings($this->user->getId(), $values);
     die("1");
 }
开发者ID:saqar,项目名称:FusionCMS-themes-and-modules,代码行数:30,代码来源:settings.php

示例4: PMA_sanitize

/**
 * Sanitizes $message, taking into account our special codes
 * for formatting.
 *
 * If you want to include result in element attribute, you should escape it.
 *
 * Examples:
 *
 * <p><?php echo PMA_sanitize($foo); ?></p>
 *
 * <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a>
 *
 * @uses    preg_replace()
 * @uses    strtr()
 * @param   string   the message
 * @param   boolean  whether to escape html in result
 *
 * @return  string   the sanitized message
 *
 * @access  public
 */
function PMA_sanitize($message, $escape = false, $safe = false)
{
    if (!$safe) {
        $message = strtr($message, array('<' => '&lt;', '>' => '&gt;'));
    }
    $replace_pairs = array('[i]' => '<em>', '[/i]' => '</em>', '[em]' => '<em>', '[/em]' => '</em>', '[b]' => '<strong>', '[/b]' => '</strong>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[tt]' => '<code>', '[/tt]' => '</code>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>');
    $message = strtr($message, $replace_pairs);
    $pattern = '/\\[a@([^"@]*)@([^]"]*)\\]/';
    if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
        $valid_links = array('http', './Do', './ur');
        foreach ($founds as $found) {
            // only http... and ./Do... allowed
            if (!in_array(substr($found[1], 0, 4), $valid_links)) {
                return $message;
            }
            // a-z and _ allowed in target
            if (!empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
                return $message;
            }
        }
        if (substr($found[1], 0, 4) == 'http') {
            $message = preg_replace($pattern, '<a href="' . PMA_linkURL($found[1]) . '" target="\\2">', $message);
        } else {
            $message = preg_replace($pattern, '<a href="\\1" target="\\2">', $message);
        }
    }
    if ($escape) {
        $message = htmlspecialchars($message);
    }
    return $message;
}
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:52,代码来源:sanitizing.lib.php

示例5: onParseContentBlock

 function onParseContentBlock($page, $name, $text, $shortcut)
 {
     $output = NULL;
     if ($name == "fotorama" && $shortcut) {
         list($pattern, $style, $nav, $autoplay) = $this->yellow->toolbox->getTextArgs($text);
         if (empty($style)) {
             $style = $this->yellow->config->get("fotoramaStyle");
         }
         if (empty($nav)) {
             $nav = $this->yellow->config->get("fotoramaNav");
         }
         if (empty($autoplay)) {
             $autoplay = $this->yellow->config->get("fotoramaAutoplay");
         }
         if (empty($pattern)) {
             $files = $page->getFiles(true);
         } else {
             $images = $this->yellow->config->get("imageDir");
             $files = $this->yellow->files->index(true, true)->match("#{$images}{$pattern}#");
         }
         if (count($files)) {
             $page->setLastModified($files->getModified());
             $output = "<div class=\"" . htmlspecialchars($style) . "\" data-nav=\"" . htmlspecialchars($nav) . "\" data-autoplay=\"" . htmlspecialchars($autoplay) . "\" data-loop=\"true\">\n";
             foreach ($files as $file) {
                 list($width, $height) = $this->yellow->toolbox->detectImageInfo($file->fileName);
                 $output .= "<img src=\"" . htmlspecialchars($file->getLocation()) . "\" width=\"" . htmlspecialchars($width) . "\" height=\"" . htmlspecialchars($height) . "\" alt=\"" . basename($file->getLocation()) . "\" title=\"" . basename($file->getLocation()) . "\" />\n";
             }
             $output .= "</div>";
         } else {
             $page->error(500, "Fotorama '{$pattern}' does not exist!");
         }
     }
     return $output;
 }
开发者ID:rainkarnichi,项目名称:yellow-extensions,代码行数:34,代码来源:fotorama.php

示例6: applyTransformation

 /**
  * Does the actual work of each specific transformations plugin.
  *
  * @param string $buffer  text to be transformed
  * @param array  $options transformation options
  * @param string $meta    meta information
  *
  * @return string
  */
 public function applyTransformation($buffer, $options = array(), $meta = '')
 {
     $options = $this->getOptions($options, array('', ''));
     //just prepend and/or append the options to the original text
     $newtext = htmlspecialchars($options[0]) . $buffer . htmlspecialchars($options[1]);
     return $newtext;
 }
开发者ID:FuhrerMalkovich,项目名称:Blogpost,代码行数:16,代码来源:PreApPendTransformationsPlugin.class.php

示例7: eh

function eh($string)
{
    if (!isset($string)) {
        return;
    }
    echo htmlspecialchars($string, ENT_QUOTES);
}
开发者ID:cheyluna,项目名称:board_exercise,代码行数:7,代码来源:html_helper.php

示例8: parse_swf

    function parse_swf($tree, $params = array())
    {
        $size = explode("x", isset($params['size']) ? $params['size'] : '740x480');
        $name = $tree->toText();
        $href = isset($params['swf']) ? $params['swf'] : $name;
        list($w, $h) = $size;
        // Can't be too sure
        $w = htmlspecialchars($w);
        $h = htmlspecialchars($h);
        $name = htmlspecialchars($name);
        $href = htmlspecialchars($href);
        /*if(!$this->swfs) $this->swfs = array();
        
        		$count = array_push($this->swfs, array(
        			"swf" => $href,
        			"width" => $size[0],
        			"height" => $size[1]));
        		$id = $count-1;
        		return $this->simple_parse($tree, "<p id=\"swf$id\" class=\"swf\">", '</p>');*/
        return <<<HTML
<div class="swf" style="width:{$w}px; height:{$h}px">
<div class="collapse">
<object width="{$w}" height="{$h}">
<param name="movie" value="{$href}"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="{$href}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="{$w}" height="{$h}"></embed>
</object>
</div>
<a href="{$href}" onclick="showSWF(this); return false">Show {$name}</a>
</div>
HTML;
    }
开发者ID:JakeCoxon,项目名称:Pages,代码行数:33,代码来源:ubbextend.php

示例9: e

 public function e($var)
 {
     if (!is_string($var)) {
         throw new Exception('$var must be a string.');
     }
     return htmlspecialchars($var, ENT_QUOTES);
 }
开发者ID:JosePathe,项目名称:phpdim2016,代码行数:7,代码来源:PhpRenderer.php

示例10: blog_get_page_content_read

/**
 * Get page components to view a blog post.
 *
 * @param int $guid GUID of a blog entity.
 * @return array
 */
function blog_get_page_content_read($guid = NULL)
{
    $return = array();
    $blog = get_entity($guid);
    // no header or tabs for viewing an individual blog
    $return['filter'] = '';
    if (!elgg_instanceof($blog, 'object', 'blog')) {
        $return['content'] = elgg_echo('blog:error:post_not_found');
        return $return;
    }
    $return['title'] = htmlspecialchars($blog->title);
    $container = $blog->getContainerEntity();
    $crumbs_title = $container->name;
    if (elgg_instanceof($container, 'group')) {
        elgg_push_breadcrumb($crumbs_title, "blog/group/{$container->guid}/all");
    } else {
        elgg_push_breadcrumb($crumbs_title, "blog/owner/{$container->username}");
    }
    elgg_push_breadcrumb($blog->title);
    $return['content'] = elgg_view_entity($blog, array('full_view' => true));
    //check to see if comment are on
    if ($blog->comments_on != 'Off') {
        $return['content'] .= elgg_view_comments($blog);
    }
    return $return;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:32,代码来源:blog.php

示例11: Create

 public static function Create($user_row, $uc = true)
 {
     if (function_exists('zuitu_uc_register') && $uc) {
         $pp = $user_row['password'];
         $em = $user_row['email'];
         $un = $user_row['username'];
         $ret = zuitu_uc_register($em, $un, $pp);
         if (!$ret) {
             return false;
         }
     }
     $user_row['username'] = htmlspecialchars($user_row['username']);
     $user_row['password'] = self::GenPassword($user_row['password']);
     $user_row['create_time'] = $user_row['login_time'] = time();
     $user_row['ip'] = Utility::GetRemoteIp();
     $user_row['secret'] = md5(rand(1000000, 9999999) . time() . $user_row['email']);
     $user_row['id'] = DB::Insert('user', $user_row);
     $_rid = abs(intval(cookieget('_rid')));
     if ($_rid && $user_row['id']) {
         $r_user = Table::Fetch('user', $_rid);
         if ($r_user) {
             ZInvite::Create($r_user, $user_row);
             ZCredit::Invite($r_user['id']);
         }
     }
     if ($user_row['id'] == 1) {
         Table::UpdateCache('user', $user_row['id'], array('manager' => 'Y', 'secret' => ''));
     }
     return $user_row['id'];
 }
开发者ID:norain2050,项目名称:zuituware,代码行数:30,代码来源:ZUser.class.php

示例12: getCategories

 /**
  *
  *
  * @return Mage_Adminhtml_Block_Catalog_Category_Tree
  */
 protected function getCategories()
 {
     $values = $this->getData('option_values');
     if (is_null($values)) {
         $values = array();
         /* @var $categoryCollection Mage_Catalog_Model_Resource_Category_Collection */
         $categoryCollection = Mage::getResourceModel('catalog/category_collection')->addAttributeToSelect('name')->addAttributeToSelect('is_active')->addFieldToFilter('is_active', '1')->setOrder('position', 'asc')->load();
         /* @var $category Mage_Catalog_Model_Category */
         foreach ($categoryCollection as $category) {
             $value = array();
             $value['id'] = $category->getId();
             $value['parent_id'] = $category->getParentId();
             if (!$category->getName()) {
                 continue;
             }
             foreach ($this->getStores() as $store) {
                 if ($store->getId()) {
                     $storeValues = $this->getStoreOptionValues($store->getId());
                 } else {
                     $storeValues[$category->getId()] = $category->getName();
                 }
                 if (isset($storeValues[$category->getId()])) {
                     $value[$store->getId()] = htmlspecialchars($storeValues[$category->getId()]);
                 } else {
                     $value[$store->getId()] = '';
                 }
             }
             $values[] = new Varien_Object($value);
         }
         $this->setData('option_values', $values);
     }
     return $values;
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:38,代码来源:Options.php

示例13: Explain

 function Explain($sql, $partial = false)
 {
     $save = $this->conn->LogSQL(false);
     if ($partial) {
         $sqlq = $this->conn->qstr($sql . '%');
         $arr = $this->conn->GetArray("select distinct distinct sql1 from adodb_logsql where sql1 like {$sqlq}");
         if ($arr) {
             foreach ($arr as $row) {
                 $sql = reset($row);
                 if (crc32($sql) == $partial) {
                     break;
                 }
             }
         }
     }
     $sql = str_replace('?', "''", $sql);
     $s = '<p><b>Explain</b>: ' . htmlspecialchars($sql) . '</p>';
     $rs = $this->conn->Execute('EXPLAIN ' . $sql);
     $this->conn->LogSQL($save);
     $s .= '<pre>';
     if ($rs) {
         while (!$rs->EOF) {
             $s .= reset($rs->fields) . "\n";
             $rs->MoveNext();
         }
     }
     $s .= '</pre>';
     $s .= $this->Tracer($sql, $partial);
     return $s;
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:30,代码来源:perf-postgres.inc.php

示例14: parse

 /**
  * Parse the correct messages into the template
  */
 protected function parse()
 {
     parent::parse();
     // grab the error-type from the parameters
     $errorType = $this->getParameter('type');
     // set correct headers
     switch ($errorType) {
         case 'module-not-allowed':
         case 'action-not-allowed':
             SpoonHTTP::setHeadersByCode(403);
             break;
         case 'not-found':
             SpoonHTTP::setHeadersByCode(404);
             break;
     }
     // querystring provided?
     if ($this->getParameter('querystring') !== null) {
         // split into file and parameters
         $chunks = explode('?', $this->getParameter('querystring'));
         // get extension
         $extension = SpoonFile::getExtension($chunks[0]);
         // if the file has an extension it is a non-existing-file
         if ($extension != '' && $extension != $chunks[0]) {
             // set correct headers
             SpoonHTTP::setHeadersByCode(404);
             // give a nice error, so we can detect which file is missing
             echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
             // stop script execution
             exit;
         }
     }
     // assign the correct message into the template
     $this->tpl->assign('message', BL::err(SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:37,代码来源:index.php

示例15: edit

    function edit()
    {
        $db = new sql();
        $db->connect();
        $res = $db->query("select * from chapters where id=" . $this->id);
        $data = $db->fetch_array($res);
        $data["text"] = htmlspecialchars($data["text"]);
        $true = $data["type"] == 4 ? " && true" : " && false";
        $db = new sql();
        $db->connect();
        $res1 = $db->query("select * from types order by id");
        while ($data1 = $db->fetch_array($res1)) {
            $i++;
            $types .= "<option" . ($data["type"] == $data1[id] ? " selected" : "") . " value=\"{$data1['id']}\">{$data1['title']}</option>";
        }
        $select = admin::getDateSelectOptions($data["time"]);
        $chid = $this->chid;
        $action = "appendEdit";
        $id = '<tr>
			<td>№</td>
			<td><input maxlength="14" name="fields[id]" size="14" value="' . $this->id . '" readonly="readonly" style="width: auto;" value="' . $this->id . '"></td>
		</tr>';
        //$res2=$db->query("select id, name, short_text, time from library where id='".$data["article"]."'");
        $state_selected[$data["state"]] = " selected";
        $header = "Редактирование";
        $lid = $this->lid;
        eval("\$content=\"" . admin::template("itemAdd", "FORMPOST", array("fields[title]" => "EXISTS", "fields[url]" => "EXISTS")) . "\";");
        $this->elements["content"] = $content;
    }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:29,代码来源:item.class.php


注:本文中的htmlspecialchars函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。