本文整理汇总了PHP中htmlEntities函数的典型用法代码示例。如果您正苦于以下问题:PHP htmlEntities函数的具体用法?PHP htmlEntities怎么用?PHP htmlEntities使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了htmlEntities函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: keyword
function keyword($word, $class)
{
$word = htmlEntities($word);
if ($this->last_class == $class) {
return $word;
} else {
$close = $this->close_url;
if (isset($this->help_pages[$class])) {
$prefix = sprintf($this->help_pages[$class], $word);
$this->close_url = '</a>';
} else {
$prefix = '';
$this->close_url = '';
}
if ($this->last_class == null) {
$this->last_class = $class;
return $prefix . '<span class="' . $class . '">' . $word;
}
$this->last_class = $class;
if ($class == null) {
return '</span>' . $close . $word;
}
return '</span>' . $close . $prefix . '<span class="' . $class . '">' . $word;
}
}
示例2: cleanUrl
/**
* Cleans a URL so it's safe to print to the browser without issues.
* @param uri String The URL to parse
* @return String The clean URL to print
*/
public static function cleanUrl($uri)
{
$result = null;
$url = htmlEntities($uri, ENT_QUOTES, 'utf-8');
$parse = parse_url($url);
$result = "{$parse['scheme']}://";
$parse['path'] = ltrim($parse['path'], '/');
foreach (array('user', 'pass', 'path', 'query', 'fragment') as $p) {
if (isset($parse[$p])) {
$parse[$p] = urlEncode($parse[$p]);
}
}
if (!empty($parse['user'])) {
$result .= "{$parse['user']}";
if (empty($parse['pass'])) {
$result .= '@';
} else {
$result .= ":{$parse['pass']}@";
}
}
$result .= "{$parse['host']}/{$parse['path']}";
if (!empty($parse['query'])) {
$result .= "?{$parse['query']}";
}
if (!empty($parse['fragment'])) {
$result .= "#{$parse['fragment']}";
}
return $result;
}
示例3: decorate
/**
* decorate
*
* @access protected
* @return mixed
* @param mixed $value
*/
function decorate($value)
{
if (is_string($value)) {
return htmlEntities($value, ENT_QUOTES, $this->list->getEncoding());
} elseif (is_array($value)) {
return array_map(array(&$this, 'decorate'), $value);
}
return $value;
}
示例4: renderCardDetails
protected function renderCardDetails($data)
{
/* may be overriden in child class */
$str = null;
if ($this->showCardDescription == 1) {
$str .= '<br>' . htmlEntities($data[TableCard::FIELD_DESCRIPTION]);
}
// if
return $str;
}
示例5: showResults
function showResults()
{
#----------------------------------------------------------------------
global $chosenEventId, $chosenRegionId, $chosenYears, $chosenShow, $chosenSingle, $chosenAverage;
#--- Try the cache
tryCache('event', $chosenEventId, preg_replace('/ /', '', $chosenRegionId), $chosenYears, preg_replace('/ /', '', $chosenShow), $chosenSingle, $chosenAverage);
#------------------------------
# Prepare stuff for the query.
#------------------------------
$eventCondition = eventCondition();
$yearCondition = yearCondition();
$regionCondition = regionCondition('result');
$limitCondition = '';
if (preg_match('/^10+/', $chosenShow, $matches)) {
$limitNumber = $matches[0];
$limitCondition = 'LIMIT ' . 2 * $limitNumber;
}
$valueSource = $chosenAverage ? 'average' : 'best';
$valueName = $chosenAverage ? 'Average' : 'Single';
#------------------------------
# Get results from database.
#------------------------------
if ($chosenShow == 'By Region') {
require 'includes/events_regions.php';
return;
}
if ($chosenShow == '100 Results' || $chosenShow == '1000 Results') {
require 'includes/events_results.php';
} else {
require 'includes/events_persons.php';
}
#------------------------------
# Show the table.
#------------------------------
startTimer();
$event = getEvent($chosenEventId);
tableBegin('results', 6);
tableCaption(true, spaced(array($event['name'], chosenRegionName(), $chosenYears, $chosenShow)));
$headerSources = $chosenAverage ? 'Result Details' : '';
tableHeader(explode('|', "Rank|Person|Result|Citizen of|Competition|{$headerSources}"), array(0 => "class='r'", 2 => "class='R2'", 5 => 'class="f"'));
$ctr = 0;
foreach ($results as $result) {
extract($result);
$ctr++;
$no = isset($previousValue) && $value == $previousValue ? ' ' : $ctr;
if ($limitCondition && $no > $limitNumber) {
break;
}
tableRow(array($no, personLink($personId, $personName), formatValue($value, $event['format']), htmlEntities($countryName), competitionLink($competitionId, $competitionName), formatAverageSources($chosenAverage, $result, $event['format'])));
$previousValue = $value;
}
tableEnd();
stopTimer("printing the table");
}
示例6: render
/**
* Renders this form for HTML viewing.
* @param view Zend_View_Interface A view controller to incorporate into
* the rendering scheme.
* @return String The rendered form
*/
public function render(Zend_View_Interface $view = null)
{
$attribs = null;
foreach ($this->_attribs as $key => $attrib) {
$attrib = htmlEntities($attrib, ENT_QUOTES, 'utf-8');
$attribs .= (empty($attribs) ? null : chr(32)) . "{$key}='{$attrib}'";
}
$result = "\n\t\t\t\t\t<form method='{$this->getMethod()}'{$attribs}>\n";
foreach ($this->_elements as $element) {
$result .= $element->render($view);
}
return "{$result}\n\t\t\t\t\t</form>\n\t\t\t\t";
}
示例7: keyword
function keyword($word, $class)
{
$word = htmlEntities($word, ENT_COMPAT, 'UTF-8');
if ($this->last_class == $class) {
return $word;
} else {
if ($this->last_class == null) {
$this->last_class = $class;
return '<span class="' . $class . '">' . $word;
}
$this->last_class = $class;
if ($class == null) {
return '</span>' . $word;
}
return '</span><span class="' . $class . '">' . $word;
}
}
示例8: choice
function choice($id, $caption, $options, $chosenOption)
{
#----------------------------------------------------------------------
$result = "<label for='{$id}'>";
$result .= $caption ? "{$caption}:<br />" : '';
$result .= "<select class='drop' id='{$id}' name='{$id}'>\n";
$chosen = urlEncode($chosenOption);
foreach ($options as $option) {
$nick = urlEncode($option[0]);
$text = htmlEntities($option[1], ENT_QUOTES, "UTF-8");
$selected = $chosen && $nick == $chosen ? " selected='selected'" : "";
$result .= "<option value='{$nick}'{$selected}>{$text}</option>\n";
}
$result .= "</select>";
$result .= "</label>";
return $result;
}
示例9: renderImg
public static function renderImg($src, $title, $htmlClass, $onclick = null)
{
/* src needs to be an absolute path */
$str = '<img ';
$str .= 'src="' . OpfApplicationConfig::APP_CALLBACK_URL . '/' . $src . '" ';
if (!is_null($title)) {
$str .= ' title="' . htmlEntities($title) . '" ';
}
// if
if (!is_null($htmlClass)) {
$str .= ' class="' . $htmlClass . '" ';
}
// if
if (!is_null($onclick)) {
$str .= 'style="cursor: pointer;" onclick="' . $onclick . '" ';
}
// if
$str .= '>';
return $str;
}
示例10: outputDir
function outputDir($directory, $prefix = "")
{
global $currentTest, $currentTestPath, $currentTestName, $currentDirPath;
$list = scandir($directory);
foreach ($list as $listItem) {
if ($listItem[0] == ".") {
continue;
}
$name = $listItem;
$listItemPath = $directory . $listItem;
$listItem = $prefix . $listItem;
if (is_dir($directory . "/" . $listItem)) {
$listItem .= "/";
$listItemPath .= "/";
$href = "?test=" . urlencode($listItem);
$hrefAll = "?all&test=" . urlencode($listItem);
if (substr($currentTest, 0, strlen($listItem)) != $listItem) {
echo '<a href="' . $hrefAll . '" class="test-set-group-all">(all)</a>';
echo '<a href="' . $href . '" class="test-set-group-name">' . htmlentities($name) . '</a>';
} else {
echo '<a href="' . $hrefAll . '" class="test-set-group-all">(all)</a>';
echo '<span class="test-set-group-name selected">' . htmlentities($name) . '</span>';
echo '<div class="test-set-group">';
$currentTestName .= $name . " / ";
$currentDirPath = $listItemPath;
outputDir($listItemPath, $listItem);
echo '</div>';
}
} elseif (substr($listItem, strlen($listItem) - 3) == ".js") {
$name = substr($name, 0, strlen($name) - 3);
if ($listItem == $currentTest) {
$currentTestPath = $listItemPath;
$currentTestName .= $name;
echo '<span class="test-set selected">' . htmlEntities($name) . '</span>';
} else {
$href = "?test=" . urlencode($listItem);
echo '<a href="' . $href . '" class="test-set">' . htmlEntities($name) . '</a>';
}
}
}
}
示例11: wddump
/**
* Output debug data
* Input var $debug_input_data must be an array
* Recommended usage:
* wddump( array(basename(__FILE__), $debugdata) );
*/
function wddump($debug_input_data = false)
{
if (!WDFAQ_DEBUG or !$debug_input_data) {
return false;
} else {
foreach ($debug_input_data as $debug_data) {
echo '<div class="wdfaq-debugdata"><pre>';
if (is_array($debug_data)) {
echo '<ul>';
foreach ($debug_data as $key => $value) {
echo '<li>Key: ' . htmlEntities($key) . '<br />Value: ' . htmlEntities($value) . '</li>';
}
echo '</ul>';
} else {
var_dump($debug_data);
}
echo '</pre></div>';
}
return true;
}
}
示例12: getDynaDescription
function getDynaDescription($text = '', $excerpt_length = 25)
{
global $modx;
$text = str_replace(']]>', ']]>', $text);
/* remove line breaks */
$text = str_replace("\n", ' ', $text);
$text = str_replace("\r", ' ', $text);
/* entify chars */
$text = htmlEntities($text);
/* remove special MODx tags - chunks, snippets, etc.
* If we don't do this they'll end up expanded in the description.
*/
$text = $modx->stripTags($text);
$words = preg_split("/\\s+/", $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '...');
$text = implode(' ', $words);
}
return trim(stripslashes($text));
}
示例13: printBuildTable
/**
* @brief Prints build table.
*
* @param buildsets Array of buildsets to display.
* @param builders Array of builders (arrays of builds per buildset).
*/
function printBuildTable($buildsets, $builders)
{
// sort builders by their name
uksort($builders, "builderCmp");
// output table header
print '<table class="dashboard"><tr><td></td>' . "\n";
foreach ($buildsets as $buildset) {
$ts = gmdate('Y-m-d H:i:s', $buildset->timestamp) . ' UTC';
print "<td class='revision' title='{$ts}'>";
print '#' . htmlentities($buildset->buildsetid) . ': ';
print htmlentities($buildset->revision);
print "<br/><span class='name'>" . htmlentities($buildset->name) . '</span>';
print "</td>\n";
}
foreach ($builders as $buildername => $builderinfo) {
print "<tr>\n";
print '<td>' . htmlentities($buildername) . "</td>\n";
foreach ($buildsets as $buildset) {
$buildsetid = $buildset->buildsetid;
if (array_key_exists($buildsetid, $builderinfo)) {
$status = $builderinfo[$buildsetid]->status;
} else {
$status = '-';
}
if (statusHasOutput($status)) {
// FIXME: might need some kind of escaping here
$build_url = htmlEntities(WEB_ROOT . "/builds/{$buildsetid}/{$buildername}", ENT_QUOTES);
$cell = "<a href='{$build_url}'>{$status}</a>";
} else {
$cell = $status;
}
$class = classFromStatus($status);
print "<td class='{$class}'>{$cell}</td>\n";
}
print "</tr>\n";
}
print "</table>\n";
}
示例14: Kizano_View_Escape
function Kizano_View_Escape($input)
{
$result = htmlEntities($input, ENT_QUOTES, 'utf-8');
return $result;
}
示例15: addslashes
<?php
$titre = "Connexion";
include_once "connexion_base.php";
include_once "utile.php";
include_once "header.php";
$probleme = "";
if (isset($_POST["send"])) {
if (isset($_POST["pseudo"]) && isset($_POST["motDePasse"]) && !empty($_POST["pseudo"]) && !empty($_POST["motDePasse"])) {
//recuperation des données du formulaire
$pseudo = addslashes(htmlEntities($_POST["pseudo"]));
$motDePasse = md5(addslashes(htmlEntities($_POST["motDePasse"])));
//requete
$sql = "SELECT Pseudo, Nom, Prenom, Avatar, Aires, CalculsElementaires, ChangementDunites, Configurations, EcrituresLitterales, Equations, FonctionLineaire, Grandeurs, Inequations, NombresEntiers, NombresRationnels, NotionDeFonction, NotionDeProbabilite, Statistique, Volumes, Score FROM individu WHERE Pseudo='{$pseudo}' and MotDePasse='{$motDePasse}'";
//envoi de la requete
$resultat1 = $connexion->query($sql);
if ($resultat1->rowCount() > 0) {
//l'utilisateur existe
session_start();
$resultat2 = $resultat1->fetchALL(PDO::FETCH_ASSOC);
foreach ($resultat2[0] as $k => $v) {
$_SESSION[$k] = $v;
}
header("Location:index.php");
} else {
echo "<script type=\"text/javascript\">";
echo "alert('Erreur de pseudo ou de mot de passe');";
echo "window.history.back();";
echo "</script>";
}
}