本文整理汇总了PHP中dechex函数的典型用法代码示例。如果您正苦于以下问题:PHP dechex函数的具体用法?PHP dechex怎么用?PHP dechex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dechex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$user = $this->getUser();
$params = $this->extractRequestParams();
// If we're in JSON callback mode, no tokens can be obtained
if ($this->lacksSameOriginSecurity()) {
$this->dieUsage('Cannot obtain a centralauthtoken when using a callback', 'hascallback');
}
if ($user->isAnon()) {
$this->dieUsage('Anonymous users cannot obtain a centralauthtoken', 'notloggedin');
}
if (CentralAuthHooks::hasApiToken()) {
$this->dieUsage('Cannot obtain a centralauthtoken when using centralauthtoken', 'norecursion');
}
$centralUser = CentralAuthUser::getInstance($user);
if (!$centralUser->exists() || !$centralUser->isAttached()) {
$this->dieUsage('Cannot obtain a centralauthtoken without an attached global account', 'notattached');
}
$data = array('userName' => $user->getName(), 'token' => $centralUser->getAuthToken());
global $wgMemc;
$loginToken = MWCryptRand::generateHex(32) . dechex($centralUser->getId());
$key = CentralAuthUser::memcKey('api-token', $loginToken);
$wgMemc->add($key, $data, 60);
$this->getResult()->addValue(null, $this->getModuleName(), array('centralauthtoken' => $loginToken));
}
示例2: doMath
function doMath($val, $idx, &$values)
{
$offset = 12288;
$ret = dechex($val * 8 + $offset);
$values[$idx][0] = $ret[0] . $ret[1];
$values[$idx][1] = $ret[2] . $ret[3];
}
示例3: LIBDBERROR
function LIBDBERROR($num,$st) {
@ob_get_clean();
ob_start();
echo "\nLIBDB: [ ".dechex($num)." ] $st\n" . mysql_error()."\n";
debug_print_backtrace();
die(json_encode(array("err" => ob_get_clean())));
}
示例4: rgbToHex
function rgbToHex($red, $green, $blue, $format = false)
{
$red = intval($red);
$green = intval($green);
$blue = intval($blue);
if ($red >= 0 && $red <= 255 && $green >= 0 && $green <= 255 && $blue >= 0 && $blue <= 255) {
$redhex = strval(dechex($red));
$greenhex = strval(dechex($green));
$bluehex = strval(dechex($blue));
if (strlen($redhex) < 2) {
$redhex = strval("0" . $redhex);
}
if (strlen($greenhex) < 2) {
$greenhex = strval("0" . $greenhex);
}
if (strlen($bluehex) < 2) {
$bluehex = strval("0" . $bluehex);
}
if ($format) {
return "#" . $redhex . $greenhex . $bluehex;
} else {
return $redhex . $greenhex . $bluehex;
}
} else {
return false;
}
}
示例5: RGB2HEX
/**
* @desc Convert decimal color to #ffffff
*/
function RGB2HEX($r, $g, $b)
{
$r = $r < 16 ? '0' . dechex($r) : dechex($r);
$g = $g < 16 ? '0' . dechex($g) : dechex($g);
$b = $b < 16 ? '0' . dechex($b) : dechex($b);
return "#{$r}{$g}{$b}";
}
示例6: efBlahtexParserBeforeTidy
/**
* Hook function for ParserBeforeTidy
*
* HTML Tidy does not understand MathML, and
* Sanitizer::normalizeCharReferences() does not know about plane-1
* entities like 𝒜 . Therefore, we replace all MathML tags with
* placeholders. The original MathML is stored in $parser.
*/
function efBlahtexParserBeforeTidy(&$parser, &$text)
{
global $wgBlahtexMathContent, $wgBlahtexMathTags;
$mathtags = array();
$endtag = "</math>";
$stripped = "";
$pos = 0;
$rand = dechex(mt_rand(0, 0x7fffffff)) . dechex(mt_rand(0, 0x7fffffff));
$n = 1;
while (TRUE) {
$res = preg_match("/<math[^>]*>/i", $text, $matches, PREG_OFFSET_CAPTURE, $pos);
if ($res == 0) {
break;
}
$pos2 = stripos($text, $endtag, $matches[0][1]);
if ($pos2 == 0) {
break;
}
$stripped .= substr($text, $pos, $matches[0][1] - $pos);
$marker = "UNIQ-blahtex-{$rand}" . sprintf('%08X', $n++) . '-QINU';
$stripped .= $marker;
$pos = $pos2 + strlen($endtag);
$mathtags[$marker] = substr($text, $matches[0][1], $pos - $matches[0][1]);
}
$parser->blahtexMathtags = $mathtags;
$text = $stripped . substr($text, $pos);
return true;
}
示例7: parse
function parse($code = null, $expect = false)
{
$end = true;
if (!$code) {
$code = $this->read();
}
do {
$rule = $this->resolver->resolveSymbol($code, $expect);
$fun = $rule->func;
$num = ord($code);
$this->logMsg("llamando {$fun} con code {$code} y num {$num} hex 0x" . dechex($num) . " offset " . $this->stream->pos);
$value = $this->{$fun}($code, $num);
if ($value instanceof HessianIgnoreCode) {
$end = false;
$code = $this->read();
} else {
$end = true;
}
} while (!$end);
$filter = $this->filterContainer->getCallback($rule->type);
if ($filter) {
$value = $this->filterContainer->doCallback($filter, array($value, $this));
}
if (is_object($value)) {
$filter = $this->filterContainer->getCallback($value);
if ($filter) {
$value = $this->filterContainer->doCallback($filter, array($value, $this));
}
}
return $value;
}
示例8: fakeGroup
function fakeGroup()
{
$randomDec = rand(1040, 1071);
// 1040 first letter, 1071 last letter in Cyrillic UNICODE table
$hex = dechex($randomDec);
return strval(rand(1000, 9000)) . mb_convert_encoding("&#x{$hex};", 'UTF-8', 'HTML-ENTITIES');
}
示例9: brightness
protected function brightness($colourstr, $steps)
{
$colourstr = str_replace('#', '', $colourstr);
$rhex = substr($colourstr, 0, 2);
$ghex = substr($colourstr, 2, 2);
$bhex = substr($colourstr, 4, 2);
$r = hexdec($rhex);
$g = hexdec($ghex);
$b = hexdec($bhex);
$r = max(0, min(255, $r + $steps));
$g = max(0, min(255, $g + $steps));
$b = max(0, min(255, $b + $steps));
$decheyr = dechex($r);
if (strlen($decheyr) == 1) {
$decheyr = "0" . $decheyr;
}
$decheyg = dechex($g);
if (strlen($decheyg) == 1) {
$decheyg = "0" . $decheyg;
}
$decheyb = dechex($b);
if (strlen($decheyb) == 1) {
$decheyb = "0" . $decheyb;
}
return '#' . $decheyr . $decheyg . $decheyb;
}
示例10: smarty_modifier_fagify
/**
* Smarty spacify modifier plugin
*
* Type: modifier<br>
* Name: fagify<br>
* Purpose: COLOURS LOL
* @author OwlManAtt <owlmanatt@starchan.org>
* @param string
* @return string
*/
function smarty_modifier_fagify($string)
{
$FAG = array('#00FFFF', '#FF7F50', '#7FFF00', '#DC143C', '#8B008B', '#8FBC8F', '#CD5C5C', '#7CFC00', '#FA8072', '#2E8B57', '#9ACD32', '#CCFFFF', '#99FFCC', '#FFFF33', '#99CC00', '#FF99CC', '#CC99FF', '#9933CC', '#FF3366', '#990066', '#66FF33', '#0099CC', '#669999', '#0033FF', '#003366', '#666600', '#0000CC', '#FF3300', '#336699', '#006666');
$IGNORE = array(' ', "\n");
$final = '';
$string = str_split($string);
foreach ($string as $index => $char) {
if (in_array($char, $IGNORE) == false) {
$color = $FAG[array_rand($FAG)];
$background = '#';
$background .= str_pad(dechex(255 - hexdec(substr($color, 1, 2))), 2, '0', STR_PAD_LEFT);
$background .= str_pad(dechex(255 - hexdec(substr($color, 3, 2))), 2, '0', STR_PAD_LEFT);
$background .= str_pad(dechex(255 - hexdec(substr($color, 5, 2))), 2, '0', STR_PAD_LEFT);
$style = "color: {$color}; background: {$background}; font-size: large; font-weight: bold;";
if (rand(1, 200) > 100) {
$style .= ' text-decoration: blink;';
}
$final .= "<span style='{$style}'>{$char}</span>";
} else {
$final .= $char;
}
}
// end loop
return $final;
}
示例11: obfuscate
protected function obfuscate($num)
{
if (rand(0, 1) < 0.5) {
return '0x' . dechex($num);
}
return $num;
}
示例12: NumberToHex
function NumberToHex($pLngNumber, $pLngLength)
{
$this->rep = str_repeat("0", $pLngLength);
$this->hex = dechex($pLngNumber);
$this->tot = $this->rep . $this->hex;
return substr($this->tot, strlen($this->tot) - $pLngLength, strlen($this->tot));
}
示例13: Get_Color
/**
* Returns the colors of the image in an array, ordered in descending order, where the keys are the colors, and the values are the count of the color.
*
* @return array
*/
function Get_Color()
{
if (isset($this->image)) {
$im = $this->image;
$imgWidth = imagesx($im);
$imgHeight = imagesy($im);
for ($y = 0; $y < $imgHeight; $y++) {
for ($x = 0; $x < $imgWidth; $x++) {
$index = imagecolorat($im, $x, $y);
$Colors = imagecolorsforindex($im, $index);
$Colors['red'] = intval(($Colors['red'] + 15) / 32) * 32;
//ROUND THE COLORS, TO REDUCE THE NUMBER OF COLORS, SO THE WON'T BE ANY NEARLY DUPLICATE COLORS!
$Colors['green'] = intval(($Colors['green'] + 15) / 32) * 32;
$Colors['blue'] = intval(($Colors['blue'] + 15) / 32) * 32;
if ($Colors['red'] >= 256) {
$Colors['red'] = 240;
}
if ($Colors['green'] >= 256) {
$Colors['green'] = 240;
}
if ($Colors['blue'] >= 256) {
$Colors['blue'] = 240;
}
$hexarray[] = substr("0" . dechex($Colors['red']), -2) . substr("0" . dechex($Colors['green']), -2) . substr("0" . dechex($Colors['blue']), -2);
}
}
$hexarray = array_count_values($hexarray);
natsort($hexarray);
$hexarray = array_reverse($hexarray, true);
return $hexarray;
} else {
die("You must enter a filename! (\$image parameter)");
}
}
示例14: emoji
function emoji($str)
{
global $filter;
$tmpArr = $acsii = array();
$s = '';
array();
$strToArray = str_split($str);
foreach ($strToArray as $i => $v) {
if ($i % 2 == 0) {
if (isset($strToArray[$i + 1])) {
$s = dechex(ord($strToArray[$i])) . dechex(ord($strToArray[$i + 1]));
//var_dump($s);
if (in_array($s, $filter)) {
$index = $i / 2;
if ($index != 0) {
$tmpArr = array($index => $s);
array_push($acsii, $tmpArr);
//will push string index and HEX code.
}
}
}
}
}
$newStr = $str;
foreach ($acsii as $asi) {
foreach ($asi as $k => $v) {
$newStr = str_replace(cnsubstr($str, $k + 1, 1), "\\&\\#" . $v, $newStr);
}
}
return $newStr;
}
示例15: indexAction
public function indexAction()
{
$url = $this->getRequest()->getParam('url');
$xmlString = '<?xml version="1.0" standalone="yes"?><response></response>';
$xml = new SimpleXMLElement($xmlString);
if (strlen($url) < 1) {
$xml->addChild('status', 'failed no url passed');
} else {
$shortid = $this->db->fetchCol("select * from urls where url = ?", $url);
$config = Zend_Registry::getInstance();
$sh = $config->get('configuration');
if ($shortid[0]) {
$hex = dechex($shortid[0]);
$short = $sh->siteroot . $hex;
} else {
//if not insert then return the id
$data = array('url' => $url, 'createdate' => date("Y-m-d h:i:s"), 'remoteip' => Pandamp_Lib_Formater::getRealIpAddr());
$insert = $this->db->insert('urls', $data);
$id = $this->db->lastInsertId('urls', 'id');
$hex = dechex($id);
$short = $sh->siteroot . $hex;
}
$xml->addChild('holurl', $short);
$xml->addChild('status', 'success');
}
$out = $xml->asXML();
//This returns the XML xmlreponse should be key value pairs
$this->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($out);
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}